2
我需要刷新頁面的一部分,我使用這個腳本在FF和Chrome中工作, 但這在IE中不起作用。部分頁面在IE中刷新
<script language="JavaScript">
<!--
var page = "ASP/include/ithome.asp";
var MyDelay = function() { ajax(page, 'scriptoutput'); };
function ajax(url,target)
{
// native XMLHttpRequest object
document.getElementById(target).innerHTML = 'sending...';
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = function() {ajaxDone(target);};
req.open("GET", url, true);
req.send(null);
// IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = function() {ajaxDone(target);};
req.open("GET", url, true);
req.send();
}
}
setTimeout(MyDelay, 12000);
}
function ajaxDone(target) {
// only if req is "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200 || req.status == 304) {
results = req.responseText;
document.getElementById(target).innerHTML = results;
} else {
document.getElementById(target).innerHTML="ajax error:\n" +
req.statusText;
}
}
}
function winOp(link, width, height) {
window.open(link, '', 'toolbar="no",scrollbars=no,resizeable="no",height=' + height + ',width=' + width + '');
}
// -->
</script>
<body background="images/Pattern.gif" onload="ajax(page,'scriptoutput')">
...
我鑫卡特,這個問題是在setTimeout的,但是當我debuged的頁面,它看起來作品。 也許req.open(「GET」,url,true)從緩存打開ASP頁面。你可以幫幫我嗎?
謝謝
L.
謝謝,它的工作原理。如何簡單:-) – leoleu 2011-12-14 18:14:11