Using the userAgent Property


Using the userAgent Property

The most comprehensive information you can get about a browser is usually to be found in the navigator.userAgent property. Unfortunately, this string is not standardized, so you must search for the information you want using the JavaScript string methods (which we'll discuss in Chapter 18, "The Date , Time , and String Objects"). Here are a few possible values for this string and what they meannote that they always start with "Mozilla" because in the early days, scripts used to search for that word before assuming standard JavaScript compatibility:

  • "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2" . This is the string returned by Netscape Navigator 6.2 for U.S. Windows 2000.

  • "Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)" . This is the string returned by Internet Explorer 5.0 for Windows 98 with digital security enabled.

  • "Mozilla/4.08 (Win98; I ;Nav)" . This is the string returned by Netscape Navigator 4.08 for Windows 98.

  • "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; COM+ 1.0.2204; .NET CLR 1.0.3512)" . This is the string returned by Internet Explorer 6.0 for Windows 2000 with .NET installed.

To get what you want from the userAgent property, you have to search for itsee the next topic.



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net