iframe加载时间限制使用javascript [英] iframe loading time limit use javascript
本文介绍了iframe加载时间限制使用javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在5000毫秒后停止加载我的iframe页面我正在使用这些但是每5000毫秒后刷新iframe会出现什么问题。请求确认请求。谢谢
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
<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加载,您可以使用以下代码在此答案:
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);
这篇关于iframe加载时间限制使用javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文