|
<html> <head></head> <body> <script language="JavaScript"> <!-- Hide JavaScript... var name = navigator.appName if { (name == "Microsoft Internet Explorer") window.location=("msie.html")  } else { window.location=("netscape.html") } // End Hiding --> </script> </body> </html> |
The navigator.appName property is used to retrieve the name of the user's browser. A condition has been set up to test whether the Browser in use is Microsoft Internet Explorer. Two different welcome pages have been created - one for Microsoft Internet Explorer and another for Netscape Navigator. If the condition is true, then the user is bounced to the Microsoft Internet Explorer version of the page; if false, then the Netscape Navigator version of the page is loaded.
Some other useful properties of the navigator object include: appVersion and platform. Check out Netscape's on-line JavaScript Reference for a complete list of properties (see "Javascipt Links").
It is important to note the difference between the = operator, and the = = operator. The = operator is used for assignment, e.g. window.location is assigned a new URL ("msie.html"). The = = operator is used to indicate equivalency.