Browser Detection using JavaScript, JavaScript Tutorial, Global Guide Line Technology.
Forum | Blog |


Basic JavaScript Guide.
 JScript Introduction.            
 JScript Why?                       
 JScript Recognitions.          
 JScript onMouseover.         
 JScript with Buttons.           
 JScript Alerts.                     
 JScript Variables.               
 JScript Operators.               
 JScript Functions.               
 JScript Prompts.                 
 JScript Conditions.             
 JScript Validations.            
 JScript Confirmation Boxes.
 JScript Browser Detection.
 JScript Redirection.            
 JScript on Links.                 
 JScript Switch.                    
 JScript Loops.                     
 JScript Events.                    
 JScript Exception Handling.
 JScript Reserve Characters. 
 JScript with Objects.            
 JScript Math Object.           
 JScript using Dates.             
 JScript using String.            
 JScript using Arrays.            
 JScript Operations.              
 JScript Handling Cookies.   
 JScript in Mapping.             
 JScript Time Out.                
 JScript Summary.                

JavaScript Tutorial >> Browser Detection using JavaScript.

     Back             Next     
Now we will discus and learn that a useful but repeatedly overrated JavaScript function is the browser detection here in JavaScript Tutorial. Sometimes we need to give specific instructions or load a new page in case the viewer uses, for instance, search etc.

The worst mistake that JavaScript beginners make is to use Browser Detection to determine what JavaScript code to run on which browser, this is can be a mistake because some browsers support JavaScript and some did not support. The problem with doing this is that there are hundreds of different browsers that we would really need to test for in order to get the code exactly right with new versions being introduced just about every day have we updated our browser detection JavaScript to recognize today's new browser versions?  If not then it would be very harmful for our website.

When people do use such a JavaScript they usually just test for the two or three most commonly used browsers and totally stuff up the webpage for anyone using a less common web browser. Even with the web browsers that they do cater for a lot of work is required to recode the JavaScript every time a new version of one of those web browsers comes out with different functionality, support of JavaScript.

Example of Browser properties Detection in JavaScript.

<SCRIPT language="JavaScript">
var browserName=navigator.appName;
if (browserName=="Netscape")
  //this portion of code will execute if the browser will be use Netscape
  if (browserName=="Microsoft Internet Explorer")
    //These below lines will be execute if the
    //Microsoft Internet Explorer will be use
    //The below lines will be be execute if any other except Netscape
    //and Microsoft Internet Explorer will be use

     Back             Next     

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright 2005 -  2023 All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 367 visitors are online now