Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Best way to include scripts with conditions like <!--[if lt IE 7 ]>..


Go to End


1004 Views

Avatar
vwd

Community Member, 166 Posts

27 October 2011 at 4:47pm

Hi,

What is the best way to include scripts such as:

    
    <!--[if lt IE 7 ]>
        <script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.2/CFInstall.min.js"></script>
        <script>window.attachEvent("onload",function(){CFInstall.check({mode:"overlay"})})</script>
    <![endif]-->  

At the moment, it seems that the only way is to stick it in the template....

If I use Requirements::customScript, it wraps everything in <script></script> such as below:

<script type="text/javascript">
    //<![CDATA[
        <!--[if lt IE 7 ]>        
            <script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.2/CFInstall.min.js"></script>            
            <script>window.attachEvent("onload",function(){CFInstall.check({mode:"overlay"})})</script>    
        <![endif]-->
    //]]>
</script>

Any ideas?

Thanks very much.
VWD