If you put that between the round brackets of an alert box it will tell you if cookies have been enabled in your browser. This is usually used in an
IF Statement, though. If the answer is yes, then a cookie can be set on a user's computer. If no, then you can ask people to enable cookies.
Other navigator objects are:
Try them out in an alert box and see what they do. You can't rely on the first two, however. appName, for example, will return Netscape in Firefox and Safari. You can use userAgent to detect if someone is surfing your site with, say, an iPad. The userAgent will say something like:
"Mozilla/5.0(iPad; CPU OS 5_0_1 like Mac OS X)"
You can do some quite advanced stuff with the location object, but the main use of location is to redirect a user to another web page. For example, if you detected someone was using an iPad then you can redirect them to your iPad optimised page. The location object is used like this:
window.location = "http://www.homeandlearn.co.uk/";
After an equal sign, you type the name of the web page or site that you want
your visitors to go to. This needs to go between quotation marks. Notice the
use of a semicolon at the end of the line above. This is not strictly necessary.
But it is recommend that you separate each line of code with a semicolon. We'll
be doing that from now on.
In the next part, we'll look at window methods