Skip to main content

Search

Navigation

Sponsor: The CSS Anthology

Blog Entry

Checking the Browser

Published on the 15th of July 2005

By Ethan Poole

JavaScript can be useful in some hard spots, and a browser detecting script can be very convenient. Detecting the browser of the visitor can easily assist in cross browser web design. JavaScript allows you to access the user's browser via the navigator object:

JavaScript
<script type="text/javascript">
    var browser = navigator.appName;
    alert(browser);
</script>

You can also use another property of the navigator object known as userAgent to access a description of the browser version of the appName property. Here we can combine the two to make a cleaner alert message:

JavaScript
<script type="text/javascript">
    var browser = navigator.appName;
    var description = navigator.userAgent;
    alert(browser + &#8220;/n&#8221; + description);
</script>

Some web browsers lack the navigator object, although the latest releases of the major web browsers support it. So when your stuck between a rock and a hard spot, just think JavaScript!

Comments

Sponsor: Songbird Media Player

Applications

Categories

Use Opera

Opera 9. Innovation delivered. Download Now (external link)

Archives

Author Profile

Ethan Poole

Ethan is a student at the University of Minnesota. He is a PHP developer and the Managing Director of Lowter. Ethan is a crazy fan of the Opera (external link) web browser and he enjoys foreign language.

All Articles by Ethan

Additional Navigation

Copyright © 2004-2008 Lowter

Sponsor Links