views:

118

answers:

1

This feels like a stupid question, or one that could be answered with a little trial and error and some Googleing--but I assure you I have tried both and several ideas and am not getting the results I'm after.

Here are my JS includes for a site:

<!-- JavaScript -->
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="js/accordian.js"></script>
<!--[if IE 7]><script type="text/javascript" src="js/ie-accordian.js"></script><![endif]-->

I'm simply trying to deliver the ie-accordian.js to IE 7 and accordian.js to all other browsers. Just not having any luck keeping IE 7 from using accordian.js as opposed to the one created especially for it.

Any thoughts?

+4  A: 

You would use a ‘downlevel-revealed conditional comment’, that is one where the contents are visible to browsers that aren't IE. See Microsoft's description but note that the precise syntax they use there is needlessly-invalid HTML. Better:

<!--[if lt IE 8]>
    <script type="text/javascript" src="js/ie-accordian.js"></script>
<![endif]-->
<!--[if gte IE 8]><!-->
    <script type="text/javascript" src="js/accordian.js"></script>
<!--<![endif]-->

(You can see from SO's syntax highlighter how most browsers parse that!)

bobince