function iframeReady(iframe, fn) {
//iframe 如果 加载完成了
if (iframe.attachEvent) {
iframe.attachEvent("onload", function () {
fn && fn.call(iframe);
});
} else {
//iframe 如果 加载未完成
iframe.onload = function () {
fn && fn.call(iframe);
};
}
}
调用:
$("#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");
});