June 24, 2009

2 Browser Detection JavaScript

Browser Detection JavaScript
Browser Detection

Almost everything in this tutorial works on all Javascript-enabled browsers. However, there are some things that just don't work on certain browsers - specially on older browsers.

So, sometimes it can be very useful to detect the visitor' s browser type and version, and then serve up the appropriate information.

The Navigator Object

The Javascript Navigator object contains all information about the visitor' s browser. We are going to look at two properties of the Navigator object:

. appName - holds the name of the browser

. appVersion - holds, among other things, the version of the browser


Tutorial

<html>
<body>
<script type="text/javascript">
var browser=navigator.appName
var b_version=navigator.appVersion
var version=parseFloat (b_version)
document.write ("Browser name: "+ browser)
document.write ("<br />")
document.write ("Browser version: "+ version)
</script>
</body>
</html>

2 comments:

Anonymous said...

great site with good no of posts

Website laten maken said...

nice colour's work.. but need some good stuff.

Post a Comment

Blogger Themes

 
Powered by Blogger