HTML5 doctype在IE8中不会触发标准模式 [英] The HTML5 doctype is not triggering standards mode in IE8

查看:104
本文介绍了HTML5 doctype在IE8中不会触发标准模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为一家公司工作,我们所有的网站目前都使用XHTML 1.0过渡文档(是的,我知道它是非常古老的学校)。我想将它们全部更改为使用HTML5文档类型,因为它是向后兼容的。我想做这个开关的原因之一是因为在IE8中如果有人安装了开发工具,那么旧的XHTML文档类型会将浏览器切换到兼容模式,并将页面呈现为IE7。从阅读起,我被引导认为HTML5的doctype会设置任何页面以标准模式呈现,但是当我在暂存服务器上测试它时,它仍然会翻转成IE7呈现模式,这种情况不会发生。



奇怪的是,如果我使用HTML5 doctype在本地保存页面并打开它,它将在IE8标准模式下呈现。必须有其他东西导致它放弃兼容IE7渲染。任何想法这可能是什么?



以下是我一直在寻找的测试页的头部:

 <!DOCTYPE html> 

< html xmlns =http://www.w3.org/1999/xhtmlxmlns:og =http://opengraphprotocol.org/schema/xmlns:fb =http ://www.facebook.com/2008/fbml>
< head>

< title>伯顿 - 男士服装 - 男士时装 - 伯顿男装< / title>

< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>

< meta name =descriptioncontent =伯顿是英国领先的男装和时装零售商之一,其设计的一系列男士服装可让您看起来更加舒适。感觉很好,在伯顿男装网上寻找男士正式和休闲服饰配件/>
< meta name =keywordscontent =男装,男装,男装,男装,男装,男装,男装,男装,男装,男装,伯顿男装,伯顿男装,伯顿英国,伯顿/>

< script type =text / javascript> document.getElementsByTagName('html')[0] .className ='js';< / script>

< link rel =stylesheettype =text / csshref =http://eu.burton-menswear.com/wcsstore/ConsumerDirectStorefrontAssetStore/images/colors/color2/v3/css/print。 cssmedia =print/>


<! - [if lt IE 8]>
< link rel =stylesheethref =http://eu.burton-menswear.com/wcsstore/ConsumerDirectStorefrontAssetStore/images/colors/color2/v3/css/ie.csstype =text / cssmedia =screen,projection>
<![endif] - >

< meta http-equiv =content-languagecontent =en-gb/>

< link rel =快捷图标type =image / x-iconhref =http://eu.burton-menswear.com/favicon.ico/>
< link rel =searchtype =application / opensearchdescription + xmltitle =burton.co.uk搜索href =http://eu.burton-menswear.com/burton-search。 XML/>
<! - 启动Summit标签 - >
< script type =text / javascript>
var __stormJs =t1.stormiq.com/dcv4/jslib/3286_D92B7532_4A18_46A8_864A_5FDF1DF25844.js;
< / script>
< script type =text / javascriptsrc =http://eu.burton-menswear.com/javascript/track.js>< / script>
<! - End Summit Tag - >
<! - 启动QuBit标记 - >
< script src = // d3c3cq33003psk.cloudfront.net/opentag-31935-42109.js async defer>< / script>
<! - 结束QuBit标记 - >
< link type =text / css =stylesheethref =http://reviews.br.wcstage.arcadiagroup.ltd.uk/bvstaging/static/6028-zh_CN/bazaarvoice.css >< /链路>

< / head>


解决方案

IE 8中有几项设置会导致无论页面的HTML内容或HTTP标题如何,都可以在兼容模式下进行呈现:
$ b


  1. 页面>兼容性视图设置




    • 如果选中在兼容性视图中显示Intranet站点,则IE将在兼容性视图中呈现本地网络上的所有站点。 (这在我的开发过程中发生过几次)。

    • 如果选中包含来自Microsoft的更新网站列表,则IE将下载如果选中在兼容性视图中显示所有网站,则可以猜测发生了什么情况。

    • 工具> Internet选项>高级>浏览




      • 如果选中通过兼容性视图自动从页面布局错误中恢复,则IE有时会切换到兼容性视图(如果它认为页面布局已损坏)。



    • 最后,如果您导航到页面,然后单击页面>兼容性视图(或单击兼容性视图图标),那么该页面将以兼容性视图呈现。

    • X-UA-兼容,然后使用HTML5之类的文档类型(这样您的意图就很清楚了),请务必在测试时首先检查这些设置。


      i work for a company where all our sites currently use the XHTML 1.0 transitional doctype (yes i know it is very old school). I want to change them all to use the HTML5 doctype seeing as it is backwards compatible. One of the reasons why i want to make the switch is because in IE8 if someone has the developer tools installed then the old XHTML doctype switches the browser into compatibility mode and renders the page as IE7. From reading up on it i was led to believe that the HTML5 doctype will set any page to render in standards mode, but this is not happening when i test it on our staging server it still flips into IE7 rendering mode.

      The weird thing is if i save the page with HTML5 doctype locally and open it, it is rendering in IE8 standards mode. There must be something else causing it to drop into compatibility IE7 rendering. Any ideas what this could be?

      Below is the head of the test page i have been looking at:

          <!DOCTYPE html >
      
      <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">
      <head>
      
          <title>Burton - Mens Clothing - Mens Fashion - Burton Menswear</title>
      
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      
          <meta name="description" content="Burton is one of the UK's leading men's clothing &amp; fashion retailers, with a range of men's clothing designed to make you look &amp; feel good. Find formal &amp; casual clothes &amp; accessories for men online at Burton menswear"/>
          <meta name="keywords" content="menswear, clothes for men, clothing for men, men clothes, men's fashion, men's wear, men's clothing online, men's clothes online, men's clothes shop, burton men's, burton menswear, burton uk, burton"/>
      
          <script type="text/javascript">document.getElementsByTagName('html')[0].className = 'js';</script>
      
          <link rel="stylesheet" type="text/css" href="http://eu.burton-menswear.com/wcsstore/ConsumerDirectStorefrontAssetStore/images/colors/color2/v3/css/screen.css" />
          <link rel="stylesheet" type="text/css" href="http://eu.burton-menswear.com/wcsstore/ConsumerDirectStorefrontAssetStore/images/colors/color2/v3/css/print.css" media="print"/>
      
          <link rel="stylesheet" type="text/css" href="http://eu.burton-menswear.com/wcsstore/ConsumerDirectStorefrontAssetStore/images/colors/color2/v3/css/brand.css" />
      
          <!--[if lt IE 8]>
          <link rel="stylesheet" href="http://eu.burton-menswear.com/wcsstore/ConsumerDirectStorefrontAssetStore/images/colors/color2/v3/css/ie.css" type="text/css" media="screen, projection">
          <![endif]-->
      
          <meta http-equiv="content-language" content="en-gb" />
      
          <link rel="shortcut icon" type="image/x-icon" href="http://eu.burton-menswear.com/favicon.ico" />
          <link rel="search" type="application/opensearchdescription+xml" title="burton.co.uk Search"  href="http://eu.burton-menswear.com/burton-search.xml"/>
          <!-- Start Summit Tag -->
          <script type="text/javascript"> 
        var __stormJs = "t1.stormiq.com/dcv4/jslib/3286_D92B7532_4A18_46A8_864A_5FDF1DF25844.js";
      </script>
          <script type="text/javascript" src="http://eu.burton-menswear.com/javascript/track.js"></script>
          <!-- End Summit Tag -->
          <!-- Start QuBit Tag -->
          <script src=//d3c3cq33003psk.cloudfront.net/opentag-31935-42109.js async defer></script>
          <!-- End QuBit Tag -->
          <link type="text/css" rel="stylesheet" href="http://reviews.br.wcstage.arcadiagroup.ltd.uk/bvstaging/static/6028-en_gb/bazaarvoice.css" ></link>
      
      </head>
      

      解决方案

      There’s a couple of settings in IE 8 that can cause pages to render in Compatibility Mode, regardless of the page’s HTML content or HTTP headers:

      1. Page > Compatibility View Settings

        • If "Display intranet sites in Compatibility View" is checked, then IE will render all sites on the local network in compatibility view. (This has happened to me a few times during development.)

        • If "Include updated website lists from Microsoft" is checked, then IE will download a list of websites from Microsoft and render them all in compatibility view.

        • If "Display all websites in Compatibility View" is checked, then, well, you can guess what happens.

      2. Tools > Internet Options > Advanced > Browsing

        • If "Automatically recover from page layout errors with Compatibility View" is checked, then IE will sometimes switch to compatibility view if it thinks a page’s layout is broken.

      3. And, finally, if you navigate to a page and then click on Page > Compatibility View (or click on the compatibility view icon in the address bar), then that page will be rendered in compatibility view.

      So, although it’s worth putting X-UA-Compatible in there and using a doctype like the HTML5 one (so that your intentions are clear), always check these settings first when testing.

      这篇关于HTML5 doctype在IE8中不会触发标准模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆