您的位置:首页 > Web前端 > JavaScript

iframe切换内容页仍然能自适应大小代码(含js)

2016-08-02 16:58 351 查看
function setIframeHeight(iframe) {
if (iframe) {
var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
if (iframeWin.document.body) {
iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
}
}
};
window.onload = function () {
setIframeHeight(document.getElementById('myiframe'));//iframe的id

};

<iframe onload="setIframeHeight(this)" id="myiframe" name="item-ifram" class="ZhaoShangJiaMeng-ifram" src="ZhaoShangJiaMeng-QuanYi.html" frameborder="0" scrolling="no" ></iframe>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: