HTML标签
<iframe
id="iframe"
frameborder="0" // 0不显示边框,1显示边框
scrolling="no" //关闭滑动
>
></iframe>
JS代码中
infoLawContent({ id: this.id }).then(res => {
if (res.code == "1000") {
this.info = res.data[0];
var iframe = document.getElementById("iframe");
iframe.contentWindow.document.body.innerHTML += this.info.Content; //接口返回的内容
iframe.contentWindow.document.close(); //关闭文档流
iframe.height = iframe.contentWindow.document.body.scrollHeight; //设置高度随着内容高度增加
}
})
在网上找了iframe标签的一些功能
var iframe = document.getElementById("iframe");
document.body.appendChild(iframe );
var s = fixingHTB.innerHTML; //进入可编辑模式前存好
iframe.contentWindow.document.designMode = "on"; //文档进入可编辑模式
iframe.contentWindow.document.open(); //打开流
iframe.contentWindow.document.write(s);
iframe.contentWindow.document.close(); //关闭流
iframe.contentWindow.document.designMode ="off"; //文档进入非可编辑模式