SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot Bootfit's Avatar
    Join Date
    Jun 2005
    Location
    Liverpool, UK
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    if not - conditional statement

    Hello all - whats the conditional statement to use in the <head> tag to tell a browser to ignore a piece of javascript?

    I have a piece of script that runs great on all browsers other than Chrome and I want to exclude it from being seen/used on Chrome.

    Whats the conditional <!--[if XXXX]> statement to wrap around it?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,299
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    So far as I know, that code doesn't exist yet. You could sniff the browser with JS, but it would be better to find out why it's not working in Chrome and address that.

  3. #3
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Only Internet Explorer read conditional comments. As Ralph wrote, why not fix the script to run in Chrome too?
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  4. #4
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I've got to go with the crowd on this, instead of not sending it to chrome - FIX IT so it works.

    But as a Opera user I'm sick of scriptards basically telling me to **** off, so the notion of saying to another major browser "no" doesn't float with me.

    Though what you are looking for is called browser sniffing, and you'd have significantly more success asking about this in the javascript area instead of the HTML one... since pretty much anyone who understands building websites PROPERLY will tell you 'sniffing is bad'... while your javascript for everything whackjobs will tell you a hundred different ways of doing it in the script.

  5. #5
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Is it actually causing problems for Chrome, or is it just not running? If it isn't doing anything bad, I would just leave it as it is...

  6. #6
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,658
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    There are PHP and js browser sniffers out there you just have to search a bit. But like others said I'd just fix it.


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
  •