我需要在 5000 毫秒后停止加载我的 iframe 页面,我正在使用这些,但它每 5000 毫秒刷新一次 iframe ,这是什么问题。请修复它。谢谢
<iframe id="iframe1" src="" width="920" height="900" border="2"></iframe>
<script type="text/javascript">
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);
</script>
要停止 iframe 加载,您可以使用以下基于的代码这个答案 https://stackoverflow.com/questions/8943219/how-to-stop-page-load-in-html-static-page#10415265:
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);
jsfiddle http://jsfiddle.net/Tsmqn/7/ / jsfiddle/表演 http://jsfiddle.net/Tsmqn/7/show
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)