简体   繁体   English

IE8和怪癖模式

[英]IE8 and quirks mode

Does IE8 run in quirks mode like IE6/7? IE8是否像IE6 / 7一样以奇怪的模式运行?

I have a webpage that has some truly bizarre code. 我有一个网页,有一些真正奇怪的代码。 The content is centered with padding and negative margins. 内容以填充和负边距为中心。

It works correctly in IE6/7 and other browsers but in IE8 the content area is half as wide and not centered (flag for quirks mode). 它在IE6 / 7和其他浏览器中都能正常工作,但在IE8中,内容区域的宽度只有一半而且没有居中(怪癖模式的标志)。

The source code has three blank lines before the DOCTYPE. 源代码在DOCTYPE之前有三个空行。 I know that will throw IE6 into quirks mode. 我知道这将使IE6陷入怪癖模式。 Will it also affect IE8? 它会影响IE8吗?

I don't have access to the source so I cannot remove those lines to test it. 我无法访问源代码,因此我无法删除这些行来测试它。

Changing the doctype to HTML 5 should fix some problems. 将doctype更改为HTML 5应该可以解决一些问题。 I had an issue with min-width in IE8 using Strict doctype. 我在使用Strict doctype的IE8中遇到了min-width问题。

So changed this: 所以改变了这个:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd "> <!DOCTYPE html PUBLIC“ - // W3C // DTD XHTML 1.0 Strict // EN”“ http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ”>

To this: <!DOCTYPE html> 对此:<!DOCTYPE html>

See here: http://davidnaylor.org/blog/2008/09/ie8-and-max-width.html 请参见此处: http//davidnaylor.org/blog/2008/09/ie8-and-max-width.html

Running a few quick tests that can be found here seem to indicate that blank lines shouldn't throw IE8 into Quirks Mode (which is different to Compatability Mode that everyone seems to be confusing it with). 运行一些可在此处找到的快速测试似乎表明空白行不应该将IE8引入Quirks模式(这与Compatability模式不同,每个人似乎都在混淆它)。

I wrote a breakdown on how incredibly confusing the different modes of IE8/7 here and I didn't even include Quirks Mode in the breakdown. 我写了一篇关于如何难以置信的混乱IE8 / 7的不同模式的崩溃在这里 ,我甚至没有包括Quirks模式击穿。 A detailed description of Quirks mode can be found here (not for the original question, but others might find it interesting.) 可在此处找到Quirks模式的详细说明(不是原始问题,但其他人可能会觉得有趣。)

Today, I changed our DOCTYPE from XHTML v1.0 (Strict) to HTML5. 今天,我将DOCTYPE从XHTML v1.0(Strict)更改为HTML5。 I read somewhere that even though the IE's don't recognize the DOCTYPE yet, they will render the page in standards-compliant mode. 我在某处读到即使IE还没有识别DOCTYPE,它们也会以符合标准的模式呈现页面。

When I checked in IE8, the whole page looked whack (we have quite a bit of CSS and other styling). 当我在IE8中检查时,整个页面看起来很糟糕(我们有相当多的CSS和其他样式)。 It took a while before I realized that there wasn't anything "wrong" with the CSS, or even IE8 for that matter. 我花了一段时间才意识到CSS没有任何“错误”,甚至IE8也没有。 However, it WAS rendering in quirks mode. 但是,它在怪癖模式下呈现。

Inadvertently, I found the answer in the question posted here, specifically this comment: "The source code has three blank lines before the DOCTYPE. I know that will throw IE6 into quirks mode. Will it also affect IE8?" 不经意间,我在这里发布的问题中找到了答案,特别是这条评论:“源代码在DOCTYPE之前有三个空白行。我知道这会使IE6陷入怪癖模式。它会影响IE8吗?”

I don't know about blank lines, but when I made the change, I had used a javascript comment to "hang on to" my old DOCTYPE statement (which was ABOVE the new HTML5 DOCTYPE). 我不知道空白行,但是当我进行更改时,我使用了一个javascript注释来“挂起”我的旧DOCTYPE语句(它是新的HTML5 DOCTYPE)。 Once I removed those lines (which may have included a blank line or two), my sweating stopped and IE8 rendered in standards-compliant mode. 一旦我删除了这些行(可能包含一行或两行),我的出汗就停止了,IE8以符合标准的模式呈现。

Yes it does. 是的,它确实。 Internet Explorer's quirks mode is IE5.5. Internet Explorer的怪癖模式是IE5.5。 IE6/7/8 switch back to 5.5 when quirks mode is present. 当存在怪癖模式时,IE6 / 7/8切换回5.5。 So since it was working fine in IE6/7 it's not the quirks mode. 因为它在IE6 / 7中工作正常,所以不是怪癖模式。 There's a "Compatibility View" button in IE8 to address this issue. IE8中有一个“兼容性视图”按钮来解决这个问题。 It's not a good solution to me though. 虽然这对我来说不是一个好的解决方案。 You'll have to check your CSS code. 你必须检查你的CSS代码。

IE8 has a compatibility mode which should treat the page the way IE7 would. IE8有一个兼容模式,应该按照IE7的方式处理页面。 Have you tried viewing the page in compatibility mode? 您是否尝试在兼容模式下查看页面?

Can you post a link to the page or some of the HTML itself? 你可以发布一个链接到页面或一些HTML本身? You could try adding the meta tag to force compatibility mode? 您可以尝试添加元标记以强制兼容模式吗?

http://www.ditii.com/2008/08/28/ie8-standards-mode-and-ie7-compatibility-mode/ http://www.ditii.com/2008/08/28/ie8-standards-mode-and-ie7-compatibility-mode/

or for more info: 或了解更多信息:

http://blogs.msdn.com/ie/archive/2008/08/27/introducing-compatibility-view.aspx http://blogs.msdn.com/ie/archive/2008/08/27/introducing-compatibility-view.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM