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 3 of 3
  1. #1
    Regular Coder
    Join Date
    May 2004
    Location
    The First State
    Posts
    233
    Thanks
    9
    Thanked 0 Times in 0 Posts

    navigator.userAgent syntax

    hey all,

    I'm using this javascript to send a particular style sheet based on browser.

    Code:
    if (navigator.userAgent.indexOf("AOL") != -1) {
    	document.write("<link rel='stylesheet' href='" + css_AOL + "' type='text/css'>");
    		}
    	else {
    document.write("<link rel='stylesheet' href='" + css_other + "' type='text/css'>");
    }
    My question is can I use the following to also include Mozilla 4.0?

    Code:
    if ((navigator.userAgent.indexOf("AOL")!=-1)
    ||(navigator.userAgent.indexOf("Mozilla/4")!=-1)) {
    	document.write("<link rel='stylesheet' href='" + css_AOL + "' type='text/css'>");
    		}
    	else {
    document.write("<link rel='stylesheet' href='" + css_other + "' type='text/css'>");
    }
    thanks in advance
    finstah
    Last edited by finstah1; 06-29-2004 at 02:25 PM.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No reason why it shouldn't be possible. Have you tried it?
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    Regular Coder
    Join Date
    May 2004
    Location
    The First State
    Posts
    233
    Thanks
    9
    Thanked 0 Times in 0 Posts
    it worked. I just wanted to make sure I had the syntax correct.


  •  

    Posting Permissions

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