Javascript Navigator userAgent property returns the combination of navigation object properties such as appCodeName and appVersion. Javascript navigator userAgent property enables you to detect the name and version of any web browser such as Microsoft Internet Explorer, FireFox, and Opera etc. userAgent property of navigator returns the semi-colon separated values of Browser Name and version, OS Platform version, .Net CLR and versions installed in windows XP and above.
navigator.userAgent
or
window.navigator.userAgent
You can also access the userAgent property using window.navigator in javascript code as shows in above syntax.
<script language="javascript" type="text/javascript">
document.write(navigator.userAgent);
</script>
Above example of navigator object property userAgent returns the browser sent header information according to the client web browser used to visit the web site.
In Internet Explorer navigator.userAgent returns:
Output: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
In FireFox navigator.userAgent returns:
Output: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16
In Opera web browser navigator.userAgent returns
Output: Opera/9.00 (Windows NT 5.1; U; en)
Be the first to rate this post
Tags: javascript, javascript navigator useragent, javascript window navigator, javascript browser detection, javascript navigator object, javascript navigator properties, javascript navigator.useragent, javascript navigator.appname, javascript navigator.appversion, check cookies enabled
8/23/2008 8:41:15 PM