Thursday, April 16, 2009

Browser detection javascript

heres a javascript for the detection of the web browser used by the end user:


if(navigator.userAgent.indexOf(’Safari’)!=-1)
{ 
    alert(’safari’); 
} 
else if(navigator.userAgent.indexOf(’Gecko’)!=-1) 
{ 
    alert(’mozilla’); 
}  
else 
{ 
    if(navigator.userAgent.indexOf(’MSIE 7.0′)!=-1) 
    { 
        alert(’ie 7′); 
    } 
    else 
    { 
        alert(’ie 6′); 
    } 
}         
       

now i’ll explain you the above script: navigator.userAgent returns the full description of the user agent or web browser used by the client or end user. indexOf() function returns the character position [...]

No comments:

Post a Comment

Ideal SQL Query For Handling Error & Transcation in MS SQL

BEGIN TRY BEGIN TRAN --put queries here COMMIT; END TRY BEGIN CATCH IF @@TRANCOUNT>0 BEGIN SELECT @@ERROR,ERRO...