使用iframe标签来显示后台返回的内容

13 篇文章 0 订阅

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";    //文档进入非可编辑模式
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值