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 to the CF scene
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript if statement

    Hi I was wondering if I have the correct syntax for this javascript if statement function. Thank you and sorry for the newbie question..

    $(function() {
    if((BrowserDetect.browser == "Explorer" && BrowserDetect.version > 8) || (BrowserDetect.browser == "Chrome" && BrowserDetect.version > 10) || (BrowserDetect.browser == "Firefox" && BrowserDetect.version > 10)) {
    createNav();
    showScreen(0);
    $("#screen").hide();
    $("#photo").show().delay(5000).fadeOut();
    }

    })

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Quote Originally Posted by tchot View Post
    Hi I was wondering if I have the correct syntax for this javascript if statement function. Thank you and sorry for the newbie question..
    Looks OK to me. Why not try it?

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you! for some reason, the function doesn't work in IE and I couldn't find out why. I guess I will have to look for something else.

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,465
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Best to avoid trying to detect the browser - From Netscape 2 onward it has been possible to use feature sensing instead so that you can have your code run in ALL the browsers that support it instead of just those where the browser owner has the useragent set to identify their browser as one that you think should support it - which will exclude lots that could run the code and include some that can't;
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Tags for this Thread

    Posting Permissions

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