[请益] 判断iframe是否加载完成

楼主: tas72732002 (葱头)   2015-12-06 09:31:35
请问一下各位, javascript 或 jquery 可否等判断iframe加载完毕, 程式如下
#file.php
<iframe src="http://127.0.0.1/demo.php" frameborder="1" id="do" name="do">
</iframe>
<script>
$('#do').on('load', function(){
console.log('load the iframe ... ')
});
</script>
#demo.php
<body onload = "document.getElementById('FORM').submit();">
<form action="demo_1.php" name="demo" name="FORM" id="FORM">
<input type="submit" name="b1" style="display:none">
</form>
</body>
#demo_1.php
<? header('Location: http://127.0.0.1/demo_2.php'); # 转址到demo_2.php ?>
demmo_2.php
<?
sleep(5); # 睡5秒
echo "demo_2_end";
?>
所以程式流程是 : file.php
作者: xxxzzz (...)   2015-12-06 18:23:00
把你要执行的JS改放到demo_2
作者: rockmanalpha (KIN)   2015-12-07 20:50:00
if($(this).contents().find("body").text() =='demo_2_end') { 你要做的事 }加载demo_2.php时应该也会触发load事件 只要判断内容是dmo_2_end才处理*demo
作者: herbacin (herbacin)   2015-12-07 22:41:00
谢谢刚好碰到这问题

Links booklink

Contact Us: admin [ a t ] ucptt.com