不支持跨域
<iframe src="http://www.baidu.com" frameborder="0" width="100%" scrolling="no" onload="setIframeHeight(this)" id="pframe" name="pframe"></iframe>
<script>
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;
}
}
};
</script>
参考地址:
http://caibaojian.com/iframe-adjust-content-height.html