net_lover [原作] 本文放在這里,算作一個備份吧。 <script> var oDiv var xh function getXML() { oDiv = document.all.m oDiv.innerHTML = "正在裝載欄目數據,請稍侯......." oDiv.style.display= "" xh = new ActiveXObject("Microsoft.XMLHTTP") xh.onreadystatechange = getReady xh.open("GET",a.value,true) xh.send() } function getReady() { if(xh.readyState==4) { if(xh.status==200) { oDiv.innerHTML = "完成" } else { oDiv.innerHTML = "抱歉,裝載數據失敗。原因:" + xh.statusText } } } </script> <body> xmlhttp異步的例子: URL:<input name=a value="http://www.knowsky.com" style="width:600px"> <input onclick="getXML()" type="button" value="得到源代碼"> <input onclick="if(xh && xh.responseText) {alert(xh.responseText);oDiv.innerHTML=xh.responseText}" type="button" value="顯示源代碼"> <div id=m></div>
|