Results 1 to 8 of 8

Thread: Browser Specific Javascript Loading

  1. #1
    Join Date
    May 2009
    Posts
    6
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Browser Specific Javascript Loading

    How do I load a specific js file according to the browser in this instance for ie8?

    Is there some kind of conditional I can do, much like browser specific CSS loading, that would appear in the head of the html?

    Thanks in advance.
    Last edited by Snookerman; 06-05-2009 at 09:28 AM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Like this?:
    Code:
    <!--[if IE 8]>
    <script type="text/javascript" src="script8.js">
    //Blah
    </script>
    <![endif]-->
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    andy@tcws (06-04-2009)

  4. #3
    Join Date
    May 2009
    Posts
    6
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    That's great thanks Nile.

    So if I need IE8 to load blah1.js and all other browsers to load blah2.js would it need some kind of if/else statement? I'm not really sure of the syntax though.

    Cheers.

  5. #4
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,734
    Thanks
    46
    Thanked 216 Times in 209 Posts
    Blog Entries
    53

    Default

    You only have to do this:
    Code:
    <!--[if IE 8]>
    Script for Internet Explorer 8
    <![endif]-->
    
    <!--[if lt IE 8]><!-->
    Script for EITHER Internet Explorer lower_then_8 OR non-IE
    <!--<![endif]-->
    ===
    Arie Molendijk.
    Last edited by molendijk; 06-04-2009 at 09:59 PM.

  6. The Following User Says Thank You to molendijk For This Useful Post:

    andy@tcws (06-05-2009)

  7. #5
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    No actually... You only have to do this:
    Code:
    <!--[if IE 8]>
    <script type="text/javascript" src="blah1.js">
    //Blah
    </script>
    <![endif]-->
    <!--[if lt IE 8]><!-->
    <script type="text/javascript" src="blah2.js">
    //Blah
    </script>
    <!--<![endif]-->
    Jeremy | jfein.net

  8. The Following User Says Thank You to Nile For This Useful Post:

    andy@tcws (06-05-2009)

  9. #6
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,734
    Thanks
    46
    Thanked 216 Times in 209 Posts
    Blog Entries
    53

    Default

    Quote Originally Posted by Nile View Post
    Code:
    <!--[if IE 8]>
    <script type="text/javascript" src="blah1.js">
    //Blah
    </script>
    <![endif]-->
    <!--[if lt IE 8]><!-->
    <script type="text/javascript" src="blah2.js">
    //Blah
    </script>
    <!--<![endif]-->
    ... meaning that Nile and I agree.
    ===
    Arie.

  10. The Following User Says Thank You to molendijk For This Useful Post:

    andy@tcws (06-05-2009)

  11. #7
    Join Date
    May 2009
    Posts
    6
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Thanks guys, that's awesome. Works like a charm

    Removed the reflection from MooFlow, as it was borked in IE8 and seems to be an outstanding unresolved issue.

    Example
    Last edited by andy@tcws; 06-05-2009 at 10:43 AM.

  12. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by molendijk View Post
    ... meaning that Nile and I agree.
    ===
    Arie.
    Yes, I was saying no the the OP.

    Great glad to help!
    Jeremy | jfein.net

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •