Simple JavaScript code for browser detection:

Code JavaScript:
/**
 * Browser detection
 * @Created-On 2007-11-27 23:46:51
 */
function detectBrowser(){
	if(navigator.userAgent.indexOf("Opera")!=-1){
		return "Opera";
	}else if(navigator.userAgent.indexOf("MSIE")!=-1){
		return "MSIE";
	}else if(navigator.userAgent.indexOf("Navigator")!=-1){
		return "Netscape";
	}else if(navigator.userAgent.indexOf("Firefox")!=-1){
		return "Firefox";
	}else if(navigator.userAgent.indexOf("Safari")!=-1){
		return "Safari";
	}
}