Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2008
    Location
    Colfax, California USA
    Posts
    64
    Thanks
    3
    Thanked 5 Times in 5 Posts

    Block IE from loading javascript

    I know how to get IE to load a certain javascript and block all other browsers but how do I get IE to stop loading another javascript file that other browsers need to read.

    I'm looking for a simple code that can be put into the javascript that needs to be blocked by IE

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,150
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    This is called conditional compilation.

    See:-

    http://www.javascriptkit.com/javatut...lcompile.shtml


    Edit: rnd me is entirely corrrect. I guess that I misunderstood the question.
    When the OP said "I know how to get IE to load a certain javascript and block all other browsers"
    I understood this to mean that he was already familiar with conditional comments. As indeed it seems he was.



    Lottery: A tax on people who are bad at math.
    Last edited by Philip M; 08-25-2008 at 11:19 AM.

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,401
    Thanks
    11
    Thanked 595 Times in 575 Posts
    for a whole file, conditional comments are a lot simpler.
    plus, conditional compilation prevents compilation of your code, and forces packaging to be done by hand. most compressors for instance, throw away comments, breaking your IE version...


    Code:
    <![if !IE]><script src="myExternalJS.js"></script><![endif]>
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%

  • Users who have thanked rnd me for this post:

    rhinodog8 (08-25-2008)

  • #4
    New Coder
    Join Date
    Aug 2008
    Location
    Colfax, California USA
    Posts
    64
    Thanks
    3
    Thanked 5 Times in 5 Posts
    hmm... wierd I was using conditional comments but they didn't work for anything other than IE, but I copied yours and it worked, Guess I was writing it wrong. THANKS!


  •  

    Posting Permissions

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