HTML and CSS Reference
In-Depth Information
What Is Your Browser's Name? Version Number? Browsers support different
features, properties, and methods; for example, Internet Explorer might display a page
in a slightly different form than Firefox, one version of Mozilla might support a feature
not supported by an older version, a version of Internet Explorer might not support a
feature supported by Opera, and so on. If you take into consideration all the other
browsers and their unique features, it can be tricky to please all of the browsers all of the
time or even some of the browsers all of the time. Browser detection allows you to check
for specific browser names, versions, whether cookies are enabled, what types of plug-
ins are loaded, and so on. The navigator object contains a number of properties that
allow you to detect information about the user's browser so you can customize your Web
page in a way that is transparent to the user.
EXAMPLE 10.2
<html>
<head><title>The Navigator Object</title></head>
<body>
<h2>About The Browser</h2>
<big>
<script type="text/javascript">
1
var BrowserName= navigator.appName;
2
var BrowserVersion = navigator.appVersion ;
3
var BrowserAgent= navigator.userAgent ;
var platform=navigator.platform;
document.write("<b>The Browser's name is:</b> " +
BrowserName + "<br />");
document.write("<b>The Browser version is:</b> " +
BrowserVersion + "<br />");
document.write("<b>The Browser's \"user agent\" is:</b> " +
BrowserAgent + "<br />");
document.write("<b>The Browser's platform is:</b> " +
platform + "<br />");
</script>
</big>
</body>
</html>
EXPLANATION
1
The navigator object's appName property is the browser's name.
2
The navigator object's appVersion property is the version of the browser.
3
The userAgent property refers to the HTTP user-agent header sent from the brows-
er to server.
What Is a Browser Sniffer? A browser sniffer is a program that makes browser
detection easy. Many Web sites provide free browser sniffers that determine the types of
different browsers. Go to http://www.quirksmode.org/js/detect.html , where you will find a
 
Search WWH ::




Custom Search