您好,欢迎访问一九零五行业门户网

JS判断iframe是否加载完成的方法

本文实例讲述了js判断iframe是否加载完成的方法。分享给大家供大家参考,具体如下:
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312"> <title></title> </head> <body> <script type="text/javascript"> var isie = /msie/i.test(navigator.useragent) && !window.opera; var iframe = document.createelement("iframe"); iframe.src = "http://www.jb51.net/"; if (isie) { iframe.onreadystatechange = function(){ if(iframe.readystate == "loaded" || iframe.readystate == "complete"){ alert("loaded"); } }; } else { iframe.onload = function(){ alert("loaded"); }; } document.body.appendchild(iframe); </script> </body> </html>
或者
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312"> <title></title> </head> <body> <script type="text/javascript"> var iframe = document.createelement("iframe"); iframe.src = "http://www.jb51.net/"; if (iframe.attachevent){ iframe.attachevent("onload", function(){ alert("loaded"); }); } else { iframe.onload = function(){ alert("loaded"); }; } document.body.appendchild(iframe); </script> </body> </html>
希望本文所述对大家javascript程序设计有所帮助。
更多js判断iframe是否加载完成的方法。
其它类似信息

推荐信息