js iframe是否加载完成,加载完成执行函数

function iframeReady(iframe, fn) {post

//iframe 若是 加载完成了.net

    if (iframe.attachEvent) {iframe

        iframe.attachEvent("onload", function () {string

            fn && fn.call(iframe);io

        });event

    } else {function

//iframe 若是 加载未完成call

        iframe.onload = function () {di

            fn && fn.call(iframe);vi

        };

    }

}

调用:

$("#landPrePermissionFrame").attr("src", "http://"+CONSTANT.netServiceAddrIp+"/AppDemoLigerUI/FlowRedirectProxy.aspx");

    var $myIframe = $('#landPrePermissionFrame');

    iframeReady($myIframe[0],function psg(){

        var $myIframe = $('#landPrePermissionFrame');

        var params = {

         eventType:"flowRedirect",

         param:{

             pageName:"用地预审收件"

         }

     };

     $myIframe[0].contentWindow.postMessage(JSON.stringify(params),

     "http://"+CONSTANT.netServiceAddrIp+"/AppDemoLigerUI/FlowRedirectProxy.aspx");

    });

相关文章
相关标签/搜索