Welcome to Bucaro TecHelp!

Bucaro TecHelp
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Holiday Gift Guide
Holiday Gift Guide

The Navigator Object

The navigator object can be used to report information about the user's web browser and what computer or device they are using to visit your website. Shown below are some of the most useful navigator object properties.

Property Description
appCodeName code name of browser
appName browser name
appVersion browser version
cookieEnabled are cookies enabled?
platform computer or device
userAgent information about itself browser sends to website

Shown below is code that displays some of the navigator object property values in a message box.

<script type="text/javascript">

txt = "Browser CodeName: " + navigator.appCodeName + '\n';
txt+= "Browser Name: " + navigator.appName + '\n';
txt+= "Browser Version: " + navigator.appVersion + '\n';
txt+= "Cookies Enabled: " + navigator.cookieEnabled + '\n';
txt+= "Platform: " + navigator.platform + '\n';
txt+= "User-agent header: " + navigator.userAgent + '\n';


Using Navigator User-agent Property to Detect Mobile Devices

Because mobile devices have only a small screen some websites redirect their webpage requests to a webpage specialy designed for small screens. Shown below is code that examines the navigator object's user-Agent property to detect some mobile devices and redirect the web browser.

<script type="text/javascript">

if ((navigator.userAgent.match(/iPhone/i)) ||
(navigator.userAgent.match(/Android/i)) ||
(navigator.userAgent.match(/Windows Phone OS 7/i)))


The code uses regular expressions to find mobile devices names in the user-Agent string. The i option means the expression is case-insensitive.

There are many more user-Agent properties than listed here, but there is no standard as to which ones are available in different browser versions, and the data contained in the properties is also unreliable.

More Java Script Code:
• The if/else Structure
• Window Object Properties and Methods
• The Conditional Operator
• Java Script Arithmetic Operators
• Java Script Trigonometric Methods
• Include a Quote Character in a String
• Java Script Character Encoding and Decoding
• The Screen Object
• Access Web Page Elements With getElementById
• Cookie Power Made Easy

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2017 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268