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

Victims of Sandy Hook

Stop the Slaughter of Innocents. Congress is bought and paid for by gun lunatics and gun promotion groups. If you want to live in a safe America, help buy Congress back for America. Send a donation to Mayors Against Illegal Guns, 909 Third Avenue, 15th Floor New York, NY 10022

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:
• Interactively Set Webpage Colors
• Accessing Web Page Elements
• Find a Character or a Substring Within a String
• Java Script Data Types
• Java Script alert Message Box
• Generating Random Numbers
• Convert a Number to a String
• The continue Statement
• Java Script Include a Backslash Character in a String
• Java Script Trigonometric Methods

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Web Design Sections

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