I'm in an ethical quandary. I've written a new browser detect script that's definitely better than the old one, but I hesitated for almost a day before publishing it. I'm afraid that amateur web developers will take the function and abuse it. Nonetheless, I decided to publish. I just hope I won't be sorry a year from now.
Here it is. It uses
navigator.vendor wherever possible, because this property is much more reliable than the good old
navigator.userAgent. I also ported the whole script to one neat object that can be dropped into any script.
The script works in all browsers I possess, but on Linux, especially, there are a few obscure browsers that I haven't installed and can't test. Besides, there's no detect for Unix as opposed to Linux. Fortunately this new script allows you to easily add little objects to perform a certain detect, and I hope my readers will submit such new objects in the comments below.
The problem is that most people who use browser detects are amateurs who tend to divide the world into "Explorer" and "other" (some add a "Mozilla" category, but even that is rare) without the slightest browser knowledge. Their main reason for doing so is laziness: they refuse to take the time and trouble to understand browsers and object detection.
navigator.vendor contains reliable information about the browser, although some browsers (notably Explorer and Mozilla) don't support it. However, if all browser detect scripts were to start using
navigator.vendor in order to exclude, say, Safari, Opera, and iCab from sites, the browser vendors will be forced to react.
Their reaction will be predictable: they'll make sure that
navigator.vendor contains the value that these oh-so-clever detection scripts expect. Of course that effectively ends the property's usefulness: you'll never know if
navigator.vendor's value is real or a spoof. See section 3D of the book for a full explanation of this mechanism.
The more this script is used, the less likely it is to stay current. In order to keep this script up-to-date you should use it as little as possible.
If you like this blog, why not donate a little bit of money to help me pay my bills?
Comments are closed.