【问题标题】:IE9 Permission Denied when writing to a window - ExtJS 4 App写入窗口时IE9权限被拒绝-ExtJS 4 App
【发布时间】:2012-11-13 21:26:46
【问题描述】:
var display_setting = "toolbar=yes, location=no, directories=yes, menubar=yes,";
    display_setting += "scrollbars=yes, width=750, height=600, left=100, top=25";
    var printwin = window.open('', 'printwin', display_setting )
    printwin.document.open()
    printwin.document.write("Testing")
    printwin.document.close()

为什么上面的代码在 IE9 中会生成“Permission Denied”错误,但在 Firefox 或 Chrome 上却可以正常运行?有解决办法吗?它是一个 ExtJS 4.1 应用程序,在单个域的 Intranet 上运行。它使用了 ExtJS 历史特性,这可能是一个因素。

谢谢

【问题讨论】:

  • 在我的工作。但无法关闭

标签: javascript extjs4 internet-explorer-9


【解决方案1】:

在这一切之后,事实证明其中一个包含的脚本包含该行

document.domain = document.domain;

删除后一切正常。

【讨论】:

    【解决方案2】:

    试试这个:

    var display_setting = "toolbar=yes, location=no, directories=yes, menubar=yes,";
    display_setting += "scrollbars=yes, width=750, height=600, left=100, top=25";
    
    var printwin = window.open('about:blank', 'printwin', display_setting);
    
    printwin.document.open();
    printwin.document.write("Testing");
    
    printwin.close();
    

    test

    【解决方案3】:

    这有点远,但是您是否关闭了所有 IE 窗口并对此进行了测试?我正在考虑的可能性是,在测试时您可能打开了一个名为 printwin 的窗口,然后您离开了基本页面(或在新选项卡中打开它或尝试打开多个名为 printwin 的窗口)并再次尝试打开名称为printwin 的窗口。 printwin 窗口已经打开,但基本页面没有访问它的权限,因为它不是页面的原始打开器

    这里的关键点是窗口名称应该始终是唯一的

    【讨论】:

      【解决方案4】:

      我已经用上面的代码进行了测试,在 IE 中我只发现了一个问题,那就是在最后一行中你没有声明对象获胜......如果你提供你的要求的细节,那么我会提供帮助。我已经修改了你的代码,并在 IE 中尝试了它对我的工作正常。

      这里是测试代码。如果要关闭窗口,请使用 printwin.close() 而不是 printwin.document.close()

      <script type="text/javascript">
      function openwindowIE(){
      var display_setting = "toolbar=yes, location=no, directories=yes, menubar=yes,";
          display_setting += "scrollbars=yes, width=750, height=600, left=100, top=25";
          var printwin = window.open('', 'printwin', display_setting )
          printwin.document.open()
          printwin.document.write("Testing")
          printwin.document.close()
      }
      </script>
      <input type="button" onclick="openwindowIE()" value="go"  />
      

      【讨论】:

      • 是的,我想应该是和内网站点有关,它使用的是ExtJS 4.1。它可能会以某种我看不到的方式干扰
      【解决方案5】:

      如果我没记错的话,IE 认为,about:blank(我猜是你试图打开的)是一个不安全的网站,因此你不能与它通信。

      如果我没记错的话,您可以打开任何其他(空)html 文档并在其中写入。

      【讨论】:

      • 其实错误是从“Permission Denied”变成了“Access Denied”
      • 是的,听起来 IE8 的安全策略更差。我不知道如何解决它。
      猜你喜欢
      • 2018-11-24
      • 2011-07-18
      • 2016-11-15
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多