HTML5 iframe srcdoc的替代品?

Alternatives to HTML5 iframe srcdoc?

HTML <iframex>标记用于创建嵌入式框架。

1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
 <head>
   HTML iframe Tag
 </head>
 <body>
   &lt;iframex src ="https://www.tutorialspoint.com/index.htm" width ="100%">&lt;/iframex&gt;
 </body>
</html>

srcdoc属性指定要在iframe中显示的页面的HTML内容

srcdoc属性的替代方法是:

1
2
3
4
5
6
var doc = document.querySelector('#demo').contentWindow.document;
var content = '<html></html>';

doc.open('text/html', 'replace');
doc.write(content);
doc.close();