【发布时间】:2016-09-14 15:33:30
【问题描述】:
我有一个 htmlString。我正在将该字符串放入 iframe 中。 代码是
var iframe = document.createElement('iframe');
var html = '<html> <head></head> <body> //contents </body> </html>';
document.body.appendChild(iframe);
iframe.contentWindow.document.open();
iframe.contentWindow.document.write(html);
iframe.contentWindow.document.close();
现在我要做的是插入一个标签
<base href="some url" >
进入 htmlString 的头部。然后我想将 iframe 附加到 dom 并将 htmlString 写入该 iframe。
如何在将 htmlString 插入 iframe 之前对其进行操作?
【问题讨论】:
标签: javascript jquery html dom iframe