<iframe id="content" width="100%" frameborder="0"src="符合同源策略的路径" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true"></iframe>
// 此方法适用于未知iframe高度时调用,获取iframe内容的高度动态设置。
function setIframeHeight() {
  let iframe = document.getElementById("content");
  try {
    let bHeight = iframe.contentWindow.document.body.scrollHeight;
    let dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
    let height = Math.max(bHeight, dHeight);
    iframe.height = height;
    } catch (ex) {console.log(ex)}
  }
// 页面加载完成或合适的时间调用此方法即可。
setIframeHeight()
网友评论