如何在IE中创建一个新的HTMLDocument? [英] How to create a new HTMLDocument in IE?

查看:158
本文介绍了如何在IE中创建一个新的HTMLDocument?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

croument。 implementation.createHTMLDocument [2] 是不太知名的DOM方法之一(惊喜!)创建一个全新的HTML文档。

dcoument.implementation.createHTMLDocument [2] is one of the lesser-known DOM methods that (surprise!) creates a brand new HTML document.

毫不奇怪,浏览器支持相当差,但我发现了一些解决方法:

Unsurprisingly, browser support is rather poor, but I found some workarounds:

  • Use an XLSTProcessor (crazy stuff!) in Firefox < 4
  • Create an empty iFrame:

var iframe = document.createElement('iframe');
iframe.style = 'display: none';
iframe.src = 'data:text/html,<!DOCTYPE html><title></title><body>';
document.body.appendChild(iframe);
newHTMLDocument = iframe.contentDocument; // <- we need this.
document.body.removeChild(iframe);


由于IE不支持 data 方案在iframe,没有办法在IE中。还是在那里?

Still, since IE does not support the data scheme on iframes, there is no way to do it in IE. Or is there?

推荐答案

如何将 src 设置为 about:blank

(也许 document.write 创建一个空的HTML文档)

How about setting src to about:blank?
(And perhaps document.writeing an empty HTML document)

这篇关于如何在IE中创建一个新的HTMLDocument?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆