gpt4 book ai didi

javascript - 隐藏 DIV 时 IE9 崩溃

转载 作者:行者123 更新时间:2023-11-29 19:50:00 24 4
gpt4 key购买 nike

注意:抱歉,我还没有支持这篇文章的代码(仅限敏感生产代码)。如果稍后时间允许,我将尝试提供一个简明的工作示例。我想发表这篇文章,希望它能为其他人提供线索,帮助他们追踪类似的问题。

使用

  • Internet Explorer 9。
  • jQuery 1.9.2 和 2.0.0。
  • HTML5 文档类型

场景

  • 我将一个页面分成逻辑“屏幕”。
  • 每个屏幕都是一个由类名标识的 DIV(例如“formScreen”、“errorScreen”、“confirmationScreen”)。
  • ".formScreen"包含表单(数据输入)字段,整个页面只有一个提交按钮,该按钮从表单数据生成 JSON 包并执行 AJAX 回发。
  • 我“以某种方式”填写表格(我填写表格的顺序似乎有所不同),然后提交。
  • 提交收到响应后,代码会更新显示。

问题

提交后隐藏所有“formScreen”DIV 会导致 IE9 完全崩溃。

最初我定义了一个 formScreens 变量:

var formScreens = $(".formScreens");

然后调用:

$(formScreens).hide();  

这会导致 IE 崩溃。

我还尝试了以下,这两个选项也会导致崩溃:

var copyOfFormScreens = $("div.formScreen");

$(copyOfFormScreens).each(function ()
{
$(this).hide(); // Option 2: This fails too.
$(this).css("display", "none"); // Option 3: This fails too.
});

IE 崩溃错误

IE 崩溃时返回以下内容:

Problem signature:  Problem Event Name:   APPCRASH  Application Name: IEXPLORE.EXE  Application Version:  9.0.8112.16496  Application Timestamp:    51a55c6d  Fault Module Name:    MSHTML.dll  Fault Module Version: 9.0.8112.16496  Fault Module Timestamp:   51a55ff0  Exception Code:   c00000fd  Exception Offset: 0032ef01  OS Version:   6.1.7601.2.1.0.256.48  Locale ID:    3081  Additional Information 1: 39a4  Additional Information 2: 39a4d7f18c1c7c725934453009d2f1b9  Additional Information 3: ddcf  Additional Information 4: ddcfafd1b35f05f847ac8d3e7a7bcf12

以及在 Visual Studio 中调试时的以下内容:

Unhandled exception at 0x6302EF01 (mshtml.dll) in iexplore.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x02432F68).  Unhandled exception at 0x630A172B (mshtml.dll) in iexplore.exe: 0xC0000005: Access violation writing location 0x02430FFC.   // This error continued to show when pressing the debug "continue".

最佳答案

解决方法/解决方案

我发现了一个非常简单的解决方法。

隐藏所需元素之前,我将焦点设置到隐藏的 DIV“外部”元素(即在屏幕 DIV 隐藏后仍然可见的元素)。在我的例子中,我将焦点设置到页面中的第一个容器 DIV,它原来是隐藏 DIV 的祖先。

DIV 布局的概念:

<div class="mainContent">  
<div class="fromScreen">
</div>
<div class="fromScreen">
</div>
<div class="fromScreen">
</div>
</div>

所以我现在调用的代码是:

$(".mainContent").trigger("focus");  // Call this before the hide.
formScreens.hide(); // Crashes on submit if focus is not set to higher element first.

要点

如果在隐藏之前隐藏具有焦点的元素的 DIV 会导致问题,请将焦点移动到被隐藏的 DIV 之外的元素。

(我的解决方法受到了 http://www.3dvia.com/forums/topic/urgent-crash-in-internet-explorer-when-trying-to-hide-the-experience 的第一个响应的启发)

关于javascript - 隐藏 DIV 时 IE9 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18050813/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com