Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 13th, 2006, 01:52 AM
Registered User
 
Join Date: Nov 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Knowing the Browser Type


Hi all,

I need to find out the type of browser from the javascript. Currently i am using navigator.appVersion if the value is "Netscape" then it ll be mozilla firefox or netscape or if the value is "Microsoft Internet Explorer" then it will be IE. Will this values be same for all the versions of firefox and internet Explorer. Or is there some other way of finding the type of browser

Please Help..


zeta


 
Old November 13th, 2006, 01:44 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Why do you want to find out the browser type? It's usually not recommended to write JavaScript against a specific browser. What if a new one or a new version comes out tomorrow?

In general, it's better to do object checking instead. For example, if you want to use document.getElementById but you don't know whether the browser supports it (just an example, as most browsers *do* support it), you can do something like this:
Code:
if (document.getElementById)
{
    alert('Is Supported');
}
else
{
    alert('Is NOT Supported');
}
This is much better, because it helps you find out what a browser can do, not what version or make it is.

Cheers,

Imar





Similar Threads
Thread Thread Starter Forum Replies Last Post
traverse the whole tree without knowing the node dipsut XSLT 3 June 17th, 2011 07:49 AM
How knowing it is an integer? rtr1900 Classic ASP Basics 1 October 5th, 2006 07:40 AM
Knowing File Path x_ray VB.NET 2002/2003 Basics 8 February 15th, 2006 04:12 PM
How to email IP and browser type on page load in p method PHP How-To 1 November 11th, 2005 06:48 AM
Knowing what is added/deleted in subform? nmccamy Access 2 September 21st, 2004 02:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.