本文介绍了jQuery& IE在$('#someDiv').hide();上崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好一会儿,我挠头然后哼?"试图弄清楚为什么当我的一个页面加载了jQuery优点时IE会突然崩溃,我将罪魁祸首缩小到这一行

Well after a while of scratching my head and going "huh?" trying to figure out why IE would straight up crash when loading one of my pages loaded with jQuery goodness, I narrowed down the culprit to this line

$('div#questions').hide();

当我说IE崩溃时,我的意思是它完全崩溃了,试图做它的网页恢复废话,失败了.

And when I say IE crashes, I mean it fully crashes, attempting to do its webpage recovery nonsense that fails.

我正在运行jQuery 1.4.2并使用IE 8(尚未在任何其他版本上进行测试)

I am running jQuery 1.4.2 and using IE 8 (haven't tested with any other versions)

我当前的解决方法是:

if ($.browser.msie) { 
    window.location = "http://www.mozilla.com/en-US/products/download.html"; 
}

出于某种原因,我觉得我的IE用户对此解决方案并不满意.

For some reason I feel my IE users won't be very pleased with this solution though.

有问题的div中包含很多内容,而其他div则被隐藏并再次显示,并且所有这些工作都很好而且很花哨,只有当巨型父div被隐藏时,IE才会翻转并刺穿本身.

The div in question has a lot of content in it and other divs that get hidden and displayed again, and all of that works just fine and dandy, it is only when the giant parent div is hidden that IE flips out and stabs itself.

有人遇到过这种情况吗?或者对哪里出了问题有任何想法?

Has anyone encountered this or have any possible ideas of what is going wrong?

所有内容都包装在$(document).ready(function(){})中;而且我的代码都是内部代码,因此很遗憾无法链接它.

Everything is wrapped up in the $(document).ready(function() { }); And my code is all internal so I can't link it unfortunately.

找到IE 8崩溃代码

<ol class="actionHelp">
    <li>List the tasks (or actions) that are involved in your pattern along the top (one per column)</li>
    <li>Put the starting point in the first column and the ending point in the last column.</li>
    <li>To fill in the middle, simply ask: "What happens next?" If only one thing ever happens next, then it should get 100%. If 70% of the time one thing happens next, and 30% of the time another thing happens next, then put 70 in one box and 30 in the other.</li>
    <li>Each row should add up to 100%</li>
    <li>The last row is the exit and should not have any percentages in it.</li>                
</ol>

我不知道为什么这会在IE中引起问题,但这是CSS

I have no idea why this is causing problems in IE but here is the CSS

.actionHelp {
    margin: 0 0 0 20px;
}
.actionHelp li {
    margin: 5px 0;
}

使用无序列表而不是有序列表不会导致崩溃,但是一旦我将其切换回去,我便又重新崩溃了,这个元素并不需要被排序,我只是将其放在那儿作为使逻辑变得合理的步骤从某种意义上说,我仍然想知道为什么这会吓坏IE.

Using an unordered list instead of an ordered list results in no crashing, but once I switch it back I get the crashes all over again, this element doesn't need to be ordered I just had it there as steps which make logical sense, I would still like to know why this is freaking out IE.

jQuery + IE +隐藏ol元素= OMG IE FAIL吗?还是有解决方法?

Does jQuery + IE + hiding an ol element = OMG IE FAIL? Or is there a workaround?

似乎所有具有列表样式而不是没有列表样式的列表元素都会受到影响

It appears to be affected any list element with a list-style other than none

推荐答案

您的问题显然不是div#questions本身.您是否可以尝试删除(或注释掉)所有div#questions的内容并一次又一次地添加每个元素,直到IE重新开始崩溃?

Your problem obviously is not div#questions itself. Can you try removing (or commenting out) all of div#questions's contents and adding each element back, one at a time, until IE starts crashing again?

找到罪魁祸首后,请对该元素再次执行相同的操作,删除其所有内容,然后再添加每个元素,在每个元素之后进行测试.

Once you've found the culprit, then do the same thing again for that element, removing all of its contents and adding each element back, testing after each one.

继续这样做,直到找到问题的真正根源.我知道这是一种技术含量很低的解决方案,但通常也是最快的解决方案.

Keep doing this until you find the real source of the problem. I know this is a pretty low-tech solution, but often it's also the quickest one.

这篇关于jQuery&amp; IE在$('#someDiv').hide();上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 01:56