detectBrowser = function(){
 if ( navigator.appName == 'Opera' ) return 'Opera';
 if ( navigator.appName == 'Microsoft Internet Explorer' )  return 'MSIE';
 if ( navigator.userAgent.indexOf( 'Chrome' ) >= 0 ) return 'Chrome';
 if ( navigator.userAgent.indexOf( 'SeaMonkey' ) >= 0 ) return 'SeaMonkey';  // must test before Firefox
 if ( navigator.userAgent.indexOf( 'Safari' ) >= 0 ) return 'Safari';
 if ( navigator.userAgent.indexOf( 'Firefox' ) >= 0 ) return 'Firefox';
 return navigator.appName;
}

document.write( "browser used: " + detectBrowser() );