MozillaZine

Javascript User Agent Detection

Thursday June 3rd, 1999

Eric Krock of Netscape wrote to me and asked that I make this request to mz's readers:

Apparently there are many people out there using User Agent detection scripts that not only fail to detect IE5 and Mozilla (what will be Communicator5), but fail to detect that scripts meant for IE4 and Nav4 would also work in the 5.0 browsers. Netscape has created a more up-to-date client sniffer, and is requesting that people mention it in the signature area of their email messages - sort of a grass-roots way of getting the message out that User Agent detection has to be updated. Here's the recommended message:

-----begin
Is your JavaScript ready for Nav5 and IE5?
Get the latest JavaScript client sniffer at
http://developer.netscape.com/docs/examples/javascript/browser_type.html
-----end

I've enabled the link in the sig above solely so you can visit the page and see it for yourself...


#12 Re:Javascript User Agent Detection

by _Dan

Friday June 4th, 1999 12:56 AM

You are replying to this message

One instance where object detection completely fails is in the case of plug-in detection!!! You should for example be able to use something like this

if(navigator.plugins){ if(navigator.plugins["ShockWave"]){ // User has shockwave go to shockwave site } else{ // User doesn't have shockwave go to non-shocked site } } else{ // No plugin detection for this browser, ask the user!!! }

Now in a perfect world any browser that supported the plugins array would pass the object detection, and any one that didn't would fail allowing you to ask the user. However MS thought it would be clever, and instead of just skiping the pluggins array they pretend it works but simply return an empty collection. Inturn it passes the object detection, but fails the plugin detection because of lack of support.