zoukankan      html  css  js  c++  java
  • 判断 iframe 是否加载完成的完美方法

    1、判断 iframe 是否加载完成:
    var iframe = document.createElement("iframe");
    iframe.src = "http://www.planabc.net/";
      
    if (!/*@cc_on!@*/0) { //if not IE
        iframe.onload = function(){
            alert("Local iframe is now loaded.");
        };
    } else {
        iframe.onreadystatechange = function(){
            if (iframe.readyState == "complete"){
                alert("Local iframe is now loaded.");
            }
        };
    }
      
    document.body.appendChild(iframe);
    2、一个新的判断方法(很完美)
    var iframe = document.createElement("iframe");
    iframe.src = "http://www.planabc.net/";
      
    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);
  • 相关阅读:
    开发日记1
    探索需求2
    探索需求1
    周总结8
    周总结7
    周总结6
    周总结5
    周总结4
    周总结3
    周总结2
  • 原文地址:https://www.cnblogs.com/aaa6818162/p/2091645.html
Copyright © 2011-2022 走看看