XSLT - How to get IE consitional statements workin

2019-08-14 21:14发布

I've noticed IE conditional statements don't work in the transformed XML document. How do I get IE 6 and above to process them.

Code as follows

'<!--[if IE 6]><style type="text/css" media="all">@import "/css/ie6.css";</style>'

Thanks.

2条回答
看我几分像从前
2楼-- · 2019-08-14 21:24

I've noticed IE conditional statements don't work in the transformed XML document

This works for me with IE8:

XML file:

<?xml-stylesheet href="deleteIECond.xsl" type="text/xsl" ?>
<t/>

deleteIECond.xsl:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template match="/">
  <xsl:comment>[if gte IE 7]>
        &lt;SCRIPT LANGUAGE="Javascript">
        alert("Congratulations! You are running Internet Explorer 7 or greater.");
        &lt;/SCRIPT>
        &lt;P>Thank you for closing the message box.&lt;/P>
        <xsl:value-of disable-output-escaping="yes" select="'&lt;![endif]'"/>
  </xsl:comment>
 </xsl:template>
</xsl:stylesheet>

You can verify that this works. If negative, the most likely reason is security/permissions.

Also, please, note, that this isn't an XSLT question.

查看更多
时光不老,我们不散
3楼-- · 2019-08-14 21:34

In the end, I had to use a doctype in the document. IE was going into quirks mode without it and that's why I needed a conditional stylesheet in the first place.

查看更多
登录 后发表回答