Just as an experiment I’m trying to use javascript to detect Mozilla(Netscape)-based browsers and serve up their own stylesheet. Here’s what I’m using to catch the broadest range of these browsers.
//detect Netscape 4.7+
if (navigator.appName==“Netscape”&&parseFloat(navigator.appVersion)>=4.7)
Assuming the js is correct how and where do I reference the stylesheet after detection? Would it be structured in a similar fashion to a conditional comment?
Just as an experiment I’m trying to use javascript to detect Mozilla
(Netscape)-based browsers and serve up their own stylesheet. Here’s
what I’m using to catch the broadest range of these browsers.
//detect Netscape 4.7+
if (navigator.appName==“Netscape”&&parseFloat(navigator.appVersion)
=4.7)
Assuming the js is correct how and where do I reference the
stylesheet after detection? Would it be structured in a similar
fashion to a conditional comment?
Todd
You would write a reference to it using document.write, if you’re
inside the JavaScript domain. If you are doing this in PHP, then
simply echo out the link that way.
//JavaScript
if (navigator.appName == "Netscape" && parseFloat
Thanks. I hadn’t considered PHP, I wonder if that would be
preferable. I’ll have to research that.
Todd
On Nov 7, 2007, at 5:43 PM, Walter Lee Davis wrote:
You would write a reference to it using document.write, if you’re
inside the JavaScript domain. If you are doing this in PHP, then
simply echo out the link that way.
//JavaScript
if (navigator.appName == "Netscape" && parseFloat
PHP browser detection is very crude compared to JavaScript. There are numerous wrappers out there, but they amount to endless regular expressions applied to whatever the browser (and/or any intermediate cache servers) sends as its “user agent” string; where JavaScript just “asks” the browser and gets a nice clean array of properties.