以前曾经以为用动态加载script或者iframe都可以实现动态加载数据,今天试验了一下发现script的方法在NS下面没有用,IFRAME的方法实现如下: sample.html: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Emu's sample of load data dynamically</TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT="emu"> <META NAME="Keywords" CONTENT="javascript,netscape,cross-browser"> <META NAME="Description" CONTENT="A sample of load data dynamically by iframe"> </HEAD> <BODY onload="out.innerHTML=''"> <iframe id=testLoadData style="width:0;height:0;visibility:hidden;position:absolute"></iframe> <input type=button onclick="test()" value="test"> <div id=output></div> <SCRIPT LANGUAGE="JavaScript"> <!-- var t; var sumFrm = document.getElementById("testLoadData"); var out = document.getElementById("output"); function test(){ sumFrm.src="test.html?"+new Date(); } function receiveData(){ for (var i = 0 ; i < arguments.length ; i++) out.innerHTML += "<br><br><a href='"+arguments[i]+"'>"+arguments[i]+"</a>"; } //--> </SCRIPT> </BODY> </HTML> test.html: <HTML> <BODY onload="setData()"> <SCRIPT LANGUAGE="JavaScript"> <!-- function setData(){ parent.receiveData("http://www.csdn.net","http://www.iecn.net"); } //--> </SCRIPT> </BODY> </HTML> 两个文件要放在同一目录下。test.html当然可以换成jsp或者php之类的任何动态页面。
IE5,NS6,MOZ1.3b下测试通过。
|