2011-08-08 46 views
1

爲什麼我的XHTML5頁面導致IE的怪異模式?爲什麼我的XHTML5頁面導致IE的怪異模式?

這裏是文檔類型和例如,包括PHP發送該MIME類型和<?

<?php header('Content-Type: application/xml;charset=UTF-8'); ?> 
<?php echo '<?';?>xml version="1.0" encoding="UTF-8"?> 
<?php echo '<?';?>xml-stylesheet type="text/xsl" href="ie-xhtml-fix.xsl"?> 
<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr"> 
<head><meta charset="UTF-8" /> 

然後即-XHTML-fix.xsl,從http://www.w3.org/MarkUp/2004/xhtml-faq#ie,是:

<stylesheet version="1.0" 
    xmlns="http://www.w3.org/1999/XSL/Transform"> 
    <template match="/"> 
     <copy-of select="."/> 
    </template> 
</stylesheet> 

對不起我必須問。我似乎無法弄清楚這一點,我找不到任何有關可能導致問題的信息。我希望它能夠在IE7中運行起來。

+0

您是否通過W3C Validator運行頁面? – Spudley

+0

是的,它完全驗證。 – Torneo

+1

... XHTML5?有HTML5和XHTML1.1,但沒有XHTML5。 – Nightfirecat

回答

2

問題似乎是您的XSLT模板正在將處理指令複製到輸出,這意味着它們在doctype之前由IE進行解析,並且這會導致IE進入Quirks模式。

試試這個XSLT來代替:

<stylesheet version="1.0" 
    xmlns="http://www.w3.org/1999/XSL/Transform"> 
    <output method="html" version="1.0" encoding="UTF-8" doctype-system="about:legacy-compat" /> 

    <!-- Copy all the child nodes of the root --> 
    <template match="/"> 
     <copy> 
      <apply-templates select="node()|@*"/> 
     </copy> 
    </template> 

    <!-- For any other node, just copy everything --> 
    <template match="node()|@*"> 
     <copy-of select="."/> 
    </template> 

    <!-- For processing instructions directly under the root, discard --> 
    <template match="/processing-instruction()" /> 
</stylesheet> 

測試和IE6及以上工作。

相關問題