Monday, April 25, 2011

javascript loading conditional statement

I've been struggling for days with getting rid of an error in IE, and to 'almost' no avail.

I just tried loading jquery 1.2.6 instead of 1.3.2, and the error has gone away (though the site is noticeably slower now).

However, I suspect I may be stuck with this solution. Is there a browser based way to include the script similar to the css conditional statements?

I can do it serverside if I need to, but client-side would be nice.

From stackoverflow
  • You can use Conditional Comments to include script only for IE.

    <!--[if IE]>
        <script type="text/javascript">
            /*  Do Stuff */
        </script>
    <![endif]-->
    

    To exclude a script block from IE:

    <![if !IE]>
        <script type="text/javascript">
            /*  Do Stuff */
        </script>
    <![endif]>
    
    pedalpete : but doing this means it will also load the other script if I can't specify NOT to load in IE.
    Ken Browning : I can't tell from your question that you're looking to run script on every browser *except* IE. The document I linked in the answer has an example of how to do this:

    You are not using Internet Explorer.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.