在项目中我们时常会遇见这样的需求,需要在一个DIV中嵌入另外的HTML。为了达成目的,总共有如下的三种解决方案。
方法一
基于Jquery的DIV镶嵌
$(selector).load('new.html');
方法二
基于原生JS嵌入
document.getElementById(id).innerHTML= '<object type='text/html' data='new.html' width='100%' height='100%'></object>'
方法三
基于iframe
<iframe src="new.html" width="100%" height="100%" frameborder="0">
您的浏览器不支持iframe,请升级
</iframe>