Search

How do I get this code to work in IE?

If you’ve followed the usage instructions it should apply the JS for IE only:

http://www.dillerdesign.com/experiment/DD_belatedPNG/#how

My hunch is that XSLT is mungling your conditional comments. Does your rendered HTML look exactly like that in the DD_belatedPNG site example? If not, could you paste some samples here?

Well I think I am getting myself all twisted.

I mean am I able to simple just insert this in the head?

<!--[if IE ]>
    <script src="script/DD_belatedPNG.js"></script>
    <script>
        /* EXAMPLE */
        DD_belatedPNG.fix('h1#logo a');
        DD_belatedPNG.fix('ul#exams table td.options a.view');
        DD_belatedPNG.fix('ul#exams table td.options a.moreInfo');
    </script>
<![endif]-->

I mean am I able to simple just insert this in the head?

Correct.

And if I go into IE and look at the source it should be there?

Because I did and it’s not appearing.

I just don’t understand it.

here is my doctype.

<xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" omit-xml-declaration="yes" encoding="UTF-8" indent="yes"/>

In XSLT <!-- --> are also comment tags. So what you have just done is tell XSLT that what you wrote are comments.

Consider removing the actual comment tags and wrapping it with <xsl:comment>.

Ok, so this:

<xsl:comment>[if IE ]</xsl:comment>
    <script src="{$root}/workspace/js/DD_belatedPNG.js" type="text/javascript"></script>
    <script>
        /* EXAMPLE */
        DD_belatedPNG.fix('#branding h1');
    </script>
<xsl:comment>[endif]</xsl:comment>

That gave me a processing error.

Try this:

<xsl:text disable-output-escaping="yes">&lt;!--[if IE ]></xsl:text>
<script src="script/DD_belatedPNG.js"></script>
<script>
        /* EXAMPLE */
        DD_belatedPNG.fix('h1#logo a');
        DD_belatedPNG.fix('ul#exams table td.options a.view');
        DD_belatedPNG.fix('ul#exams table td.options a.moreInfo');
</script>
<xsl:text disable-output-escaping="yes">&lt;![endif]--></xsl:text>

Ok, that may work. One sec…

<xsl:comment><![CDATA[[if IE]>
<link rel="stylesheet" href="http://www.foo.com/workspace/css/ie.css" type="text/css" media="screen, projection">
<![endif]]]></xsl:comment>

CDATA tags work for me.

@MrBlank’s solution is more elegant.

If you want to push it even further, you can read this post: http://www.nickfitz.co.uk/2005/10/27/ie-conditional-comments-in-xslt-10/

Fantastic.

Hmm, so creating a Utility seems to be the best way to go then.

Hmm, ok so I create this utility:

<xsl:template name="conditionalComment">
<xsl:param name="qualifier" select="'IE'"/>
<xsl:param name="contentRTF" select="''" />
<xsl:comment>[if <xsl:value-of select="$qualifier"/>]<![CDATA[>]]>
    <xsl:copy-of select="$contentRTF" />
    <![CDATA[<![endif]]]></xsl:comment>
</xsl:template>

and this is the code in my head:

   <xsl:call-template name="conditionalComment">
   <xsl:with-param name="qualifier" select="'lte IE 6'"/>
   <xsl:with-param name="contentRTF">
    &lt;script src="http://www.sjc-designpartnership.com/workspace/js/DD_belatedPNG.js"&gt;&lt;/script&gt;
    &lt;script
    /* EXAMPLE */
    DD_belatedPNG.fix('#branding h1');
    &lt;/script&gt;
   </xsl:with-param>
  </xsl:call-template>

and for some weird reason it completely removed all the content and just leaves the background colour.

Using the same utility for the ie stylesheet works fine.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details