+ Start a Discussion
radanradan 

How to prevent VF from stripping comments?

I am trying to conditionally include a style sheet based on browser type. For example -

 

<!-- [if IE]> <apex:stylesheet value="{!URLFOR($Resource.ext221, 'resources/css/FIX-v221.css')}" />
<![endif] -->

 

 The comment above is stripped out by VF processing. I saw a posting on this forum suggesting that a work around would be to replace this by:

 

&lt;!--  [if IE]> <apex:stylesheet value="{!URLFOR($Resource.ext221, 'resources/css/FIX-v221.css')}" />

<! [endif] --&gt;

 

This works for IE but on other browsers, this is not treated as a comment.

I get a 'element is not well formed' error and  the CSS is included anyway with incorrect results.. 

  

    Any help with this would be much appreciated

 

WesNolte__cWesNolte__c

Hey

 

Your post set me on the right track, and I think I've solved your issue too, try this:

 

 

<!-- This hack is necessary because SF escapes the conditional tag --> <div style="display:none"> &lt;!--[if lte IE 6]> <link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.WebRegistration, 'css/ie6.css')}" /> &lt;![endif] --&gt; </div>

 

Wes