i need to stop loading my iframe page after 5000 ms i'm use these but it's refresh the iframe every 5000 ms later what the problem . pleas fix it pleas. thanks
function setIframeSrc() {
var s = "http://lx5.in/CGIT-Results-p2-2013.php";
var iframe1 = document.getElementById('iframe1');
if ( -1 == navigator.userAgent.indexOf("MSIE") ) {
iframe1.src = s;
setTimeout(setIframeSrc, 5000);
}
else {
iframe1.location = s;
setTimeout(setIframeSrc, 5000);
}
}
setTimeout(setIframeSrc, 5000);
解决方案
To stop iframe loading you can use the following code based on this answer:
function setIframeSrc() {
var s = "http://lx5.in/CGIT-Results-p2-2013.php";
var iframe1 = document.getElementById('iframe1');
iframe1.src = s;
setTimeout(function(){
if (window.stop) {
window.stop();
} else {
document.execCommand('Stop'); // MSIE
}
}, 5000);
}
setTimeout(setIframeSrc, 5000);