iframe切换内容页仍然能自适应大小代码(含js)
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>