$('.content').append('<iframe src="https://www.baidu.com" frameborder="0" scrolling="no" id="external-frame"></iframe>')
var iframe = document.getElementById("external-frame");
iframe.onload=function(e){
if (iframe) {
var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
if (iframeWin.document.body) {
iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
}
}
};
iframe跨域报错
跨域解决方案:
iframe跨域问题:Uncaught DOMException: Blocked a frame with origin解决方法
参考网址:
自我解读:对于append进去的iframe 传统的onload事件加载执行会出现问题==》报错