...

View Full Version : navigator.userAgent syntax



finstah1
06-29-2004, 03:14 PM
hey all,

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



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?



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

Roy Sinclair
06-30-2004, 09:08 PM
No reason why it shouldn't be possible. Have you tried it?

finstah1
07-01-2004, 04:16 PM
it worked. I just wanted to make sure I had the syntax correct. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum