Java Reference
In-Depth Information
Browser Information
The window object has a number of properties and methods that provide information about
the user's browser.
Which Browser?
The window object has a navigator object that contains information about the browser
being used. Its userAgent property will return information about the browser and operat-
ing system being used. For example, if I run the following line of code, it shows that I am
using Firefox version 31.0 on Linux:
<< "Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101
Don't rely on this information though, as it can be modified by a user to masquerade as
a different browser. It's also difficult to make any sense of the string returned, because all
browsers pretend to be others to some degree. For example, every browser will include the
string " Mozilla " in its userAgent property for reasons of legacy Netscape compatibil-
Location, Location, Location
The window.location property is an object that contains information about the URL of
the current page. It contains a number of properties that provide information about different
fragments of the URL.
The href property returns the full URL as a string:
<< "
Search WWH ::

Custom Search