为什么以下抛出“对象不支持属性或方法'importNode'"在IE11? [英] Why does the following throw an "Object doesn't support property or method 'importNode'" in IE11?

查看:232
本文介绍了为什么以下抛出“对象不支持属性或方法'importNode'"在IE11?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么以下抛出对象不支持IE11中的属性或方法'importNode'

这可能是我的文档模式吗?我处于文档模式7。

Could it be my "document mode"? I am in "document mode" 7.

    <!DOCTYPE html>
    <html>
    <head>
        <script>
            function go() {
              var popUp = window.open('about:blank');
              var node = document.createElement('div');
              node.textContent = 'foo';

              var importedNode = popUp.document.importNode(node, true);
              popUp.document.body.appendChild(importedNode);
            }
        </script>
    </head>
    <body>
      <button onclick="go()">Click Me</button>
    </body>
    </html>

为了澄清我需要节点节点由开启窗口创建,我使用 importNode 以尝试在IE中使用它(Chrome不需要它)。

For clarification I want the node, node to be created by the opener window, and I am using importNode in order to attempt to get this working in IE (it is not needed for Chrome).

importNode 已添加到IE9中我认为( https://msdn.microsoft.com/en-us/library/ie/gg130964%28v=vs.85%29。 aspx )。

importNode was added in IE9 I think (https://msdn.microsoft.com/en-us/library/ie/gg130964%28v=vs.85%29.aspx).

推荐答案

您是否从硬盘本地加载页面?如果是这样,它可能会显示在Intranet区域中,因此默认为IE7兼容模式。你可以:

Are you loading the page locally from your hard drive? If so, it's likely being displayed in the Intranet zone and therefore defaulting to IE7 compatibility mode. You can:


  1. 添加MOTW 以从Internet区域加载您的页面,

  2. 从本地Web服务器提供它,

  3. 禁用自动将Intranet区域页面设置为兼容性视图(也称为IE7模式)的设置

  1. add an MOTW to load your page from the Internet zone,
  2. serve it from a local web server,
  3. disable the settings that automatically set Intranet zone pages to compatibility view (aka IE7 mode).

而且,是的,您必须处于IE9标准模式或更高版本才能使用 importNode

And, yes, you must be in IE9 standards mode or later to use importNode.

希望这会有所帮助......

Hope this helps...

- Lance

-- Lance

PS根据OP转换回答。

P.S. Coverted to answer, per OP.

这篇关于为什么以下抛出“对象不支持属性或方法'importNode'&quot;在IE11?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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