在Internet Explorer中加载网页时出现“操作已中止”错误消息

时间:2009-01-22 11:04:14

标签: javascript html internet-explorer

朋友们,我为我的项目设计了一个页面。我在那里显示数据库中的数据。

问题是它显示数据,但随后会出现一个消息框,说明:

  

Internet Explorer无法打开   互联网网站'http://localhost/ ....   操作中止

请帮我解决这个问题。

4 个答案:

答案 0 :(得分:4)

当您使用javascript并尝试在元素加载完成之前尝试修改元素时,IE中经常会出现“操作已中止”消息。

如果可能,请将脚本延迟运行到onload

答案 1 :(得分:1)

这是IE 6中的known bug。IE可能有多种原因导致中止操作。

可能的原因可能是:

  1. 您的浏览器中安装了第三方插件(通过转到IE>工具> Internet选项>高级选项卡>启用第三方浏览器扩展程序禁用它)
  2. 您正在修改DOM节点,甚至在创建之前。尝试在window.onDOMReady事件之后修改DOM节点。
  3. 正如bug所说,您可能正在使用aspx页面中的SmartNav功能。 (我不知道)

答案 2 :(得分:1)

导致此问题的最常见代码(KB927917)将从不是body元素的直接子元素的脚本追加到body元素。换句话说,从孙子节点写入body元素会引发此错误。

无错误

<body>
  <script type="text/javascript">
    document.body.appendChild(document.createElement('div'))
  </script>
</body>

操作已中止

<body>
  <div>
    <script type="text/javascript">
      document.body.appendChild(document.createElement('div'))
    </script>
  </div>
</body>

解决方案

创建一个可以写入已关闭的元素。

<body>
  <div><!-- add content to me instead of appending to the body --></div>
  <div>
    <script type="text/javascript">
      document.getElementsByTagName('div')[0].appendChild(document.createElement('div'))
    </script>
  </div>
</div>

您也可以以编程方式创建该div。

答案 3 :(得分:1)

您可以使用IE Blog提供的脚本来调查问题。 请参阅:http://blogs.msdn.com/ie/archive/2009/09/03/preventing-operation-aborted-scenarios.aspx