时间:2021-07-01 10:21:17 帮助过:6人阅读
本文实例讲述了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 = "//www.gxlcms.com/";
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 = "//www.gxlcms.com/";
if (iframe.attachEvent){
iframe.attachEvent("onload", function(){
alert("loaded");
});
} else {
iframe.onload = function(){
alert("loaded");
};
}
document.body.appendChild(iframe);
</script>
</body>
</html>以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:
如何利用JS实现仿微信支付弹窗功能
关于js传递数组参数到后台controller的方法
以上就是如何通过JS判断iframe是否加载完成的详细内容,更多请关注Gxl网其它相关文章!