时间:2021-07-01 10:21:17 帮助过:12人阅读
<iframe id='google'></iframe>
<script type='text/javascript'>
document.getElementById('google').src='http://jb51.net/';
document.getElementById('google').onload = function(){
alert ('I am google frame, now loaded');
}
</script>
在这里,也把原文提到的”判断 iframe 是否加载完成的完美方法”原文摘录至此
代码如下:
var iframe = document.createElement("iframe");
iframe.src = "//www.gxlcms.com";
if (iframe.attachEvent){
iframe.attachEvent("onload", function(){
alert("Local iframe is now loaded.");
});
} else {
iframe.onload = function(){
alert("Local iframe is now loaded.");
};
}
document.body.appendChild(iframe);