iframe

 

 

 

iframe如何触发父元素事件以及父页面控制iframe子页面元素

https://blog.csdn.net/weixin_38047955/article/details/78803291

父元素访问子元素

$('#iframeID').contents().find('#元素id')

子元素访问父元素

$(window.parent.document).find(""#元素id");
// 或者:$("#元素id",window.parent.document);

 

JS实现判断iframe是否加载完成

var iframe = document.createElement("iframe"); 
iframe.src = "blog.iinu.com.cn"; 
if (iframe.attachEvent){ 
    iframe.attachEvent("onload", function(){ 
        alert('新太潮流加载完成');
    }); 
} else { 
    iframe.onload = function(){ 
        alert('新太潮流加载完成');
    }; 
}
document.body.appendChild(iframe);

JS实现判断iframe是否加载完成

 

posted @ 2020-02-17 16:50  泠风lj  阅读(185)  评论(0编辑  收藏  举报