Return to Snippet

Revision: 660
at July 29, 2006 02:15 by kif


Updated Code
/*-----------------------------------------------------------------------------
 * Navigator
 *  Example Source
	document.write(
		(Navigator.isWinIE())  ? 'IE' + Navigator.isWinIE() + ' (Win)' :
		(Navigator.isMacIE())  ? 'IE' + Navigator.isMacIE() + ' (Mac)' :
		(Navigator.isGecko())  ? 'Mozilla (' + Navigator.isGecko() + ')' :
		(Navigator.isSafari()) ? 'Safari (' + Navigator.isSafari() + ')' :
		(Navigator.isKDE())    ? 'KDE (' + Navigator.isKDE() + ')' :
		(Navigator.isOpera())  ? 'Opera' + Navigator.isOpera() :
		(Navigator.isNN4())    ? 'NN4' :
		"I don't know."
	);
 *-------------------------------------------------------------------------- */

var Navigator = {
	_getVersion: function (a, b) {
		var t = navigator.userAgent.split(a)[1];
		return (t) ? t.split(b)[0] : false;
	},
	isOpera: function () {
		return (
			(window.opera) ?
				(document.createElementNS) ?
					(document.createCDATASection) ?
						(document.styleSheets) ? 9 : 8
					: 7
				: 6
			: false
		);
	},
	isSafari: function () {
		return (document.createCDATASection && document.createElementNS) ? Navigator._getVersion('AppleWebKit/', '(') : false;
	},
	isKDE: function () {
		return (document.createCDATASection && document.createElementNS) ? Navigator._getVersion('Konqueror/', ';') : false;
	},
	isGecko: function () {
		return (document.createCDATASection && document.createElementNS) ? Navigator._getVersion('Gecko/', ' ') : false;
	},
	isNN4: function () {
		return (document.layers && typeof document.layers == 'object') ? true : false;
	},
	isWinIE: function () {
		return (
			/*@cc_on @if (@_win64 || @_win32 || @_win16)
			(document.getElementsByTagName) ?
				(@_jscript_version > 5.6) ? 7 :
				(@_jscript_version == 5.6) ? 6 :
				(@_jscript_version == 5.5) ? 5.5 :
				5
			: 4
			@else@*/false/*@end @*/
		);
	},
	isMacIE: function () {
		return (
			/*@cc_on @if (@_mac && (@_PowerPC || @_mc680x0))
				(document.getElementsByTagName) ? 5 : 4
			@else@*/false/*@end @*/
		);
	}
};

Revision: 659
at July 26, 2006 19:30 by kif


Updated Code
/*-----------------------------------------------------------------------------
 * Browser Checker
 *  Example Source
	document.write(
		(Browser.isWinIE)  ? 'IE' + Browser.isWinIE + ' (Win)' :
		(Browser.isMacIE)  ? 'IE' + Browser.isMacIE + ' (Mac)' :
		(Browser.isGecko)  ? 'Mozilla (' + Browser.isGecko + ')' :
		(Browser.isSafari) ? 'Safari (' + Browser.isSafari + ')' :
		(Browser.isKDE)    ? 'KDE (' + Browser.isKDE + ')' :
		(Browser.isOpera)  ? 'Opera' + Browser.isOpera :
		(Browser.isNN4)    ? 'NN4' :
		"I don't know."
	);
 *-------------------------------------------------------------------------- */

var Browser = {
	getVersion: function (a, b) {
		var t = navigator.userAgent.split(a)[1];
		return (t) ? t.split(b)[0] : false;
	}
}

Browser = {
	isOpera:
		(window.opera) ?
			(document.createElementNS) ?
				(document.createCDATASection) ?
					(document.styleSheets) ? 9 : 8
				: 7
			: 6
		: false,
	isSafari:
		(document.createCDATASection && document.createElementNS) ?
			Browser.getVersion('AppleWebKit/', '(')
		: false,
	isKDE:
		(document.createCDATASection && document.createElementNS) ?
			Browser.getVersion('Konqueror/', ';')
		: false,
	isGecko:
		(document.createCDATASection && document.createElementNS) ?
			Browser.getVersion('Gecko/', ' ')
		: false,
	isNN4:
		(document.layers && typeof document.layers == 'object') ? true : false,
	isWinIE:
		/*@cc_on @if (@_win64 || @_win32 || @_win16)
		(document.getElementsByTagName) ?
			(@_jscript_version > 5.6) ? 7 :
			(@_jscript_version == 5.6) ? 6 :
			(@_jscript_version == 5.5) ? 5.5 :
			5
		: 4
		@else@*/false/*@end @*/,
	isMacIE:
		/*@cc_on @if (@_mac && (@_PowerPC || @_mc680x0))
			(document.getElementsByTagName) ? 5 : 4
		@else@*/false/*@end @*/
}

Revision: 658
at July 26, 2006 05:26 by kif


Initial Code
/*-----------------------------------------------------------------------------
 * Browser
 *  Example Source
	document.write(
		(Browser.isWinIE)  ? 'IE' + Browser.isWinIE + ' (Win)' :
		(Browser.isMacIE)  ? 'IE' + Browser.isMacIE + ' (Mac)' :
		(Browser.isGecko)  ? 'Mozilla (' + Browser.isGecko + ')' :
		(Browser.isSafari) ? 'Safari (' + Browser.isSafari + ')' :
		(Browser.isKDE)    ? 'KDE (' + Browser.isKDE + ')' :
		(Browser.isOpera)  ? 'Opera' + Browser.isOpera :
		(Browser.isNN4)    ? 'NN4' :
		"I don't know."
	);
 *-------------------------------------------------------------------------- */

var Browser = {
	getVersion: function (a, b) {
		var t = navigator.userAgent.split(a)[1];
		return (t) ? t.split(b)[0] : false;
	}
}

Browser = {
	isOpera:
		(window.opera) ?
			(document.createElementNS) ?
				(document.createCDATASection) ?
					(document.styleSheets) ? 9 : 8
				: 7
			: 6
		: false,
	isSafari:
		(document.createCDATASection && document.createElementNS) ?
			Browser.getVersion('AppleWebKit/', '(')
		: false,
	isKDE:
		(document.createCDATASection && document.createElementNS) ?
			Browser.getVersion('Konqueror/', ';')
		: false,
	isGecko:
		(document.createCDATASection && document.createElementNS) ?
			Browser.getVersion('Gecko/', ' ')
		: false,
	isNN4:
		(document.layers && typeof document.layers == 'object') ? true : false,
	isWinIE:
		/*@cc_on @if (@_win64 || @_win32 || @_win16)
		(document.getElementsByTagName) ?
			(@_jscript_version > 5.6) ? 7 :
			(@_jscript_version == 5.6) ? 6 :
			(@_jscript_version == 5.5) ? 5.5 :
			5
		: 4
		@else@*/false/*@end @*/,
	isMacIE:
		/*@cc_on @if (@_mac && (@_PowerPC || @_mc680x0))
			(document.getElementsByTagName) ? 5 : 4
		@else@*/false/*@end @*/
}

Initial URL

                                

Initial Description
Support: Fx2, Opera9, IE6
I don't have warrant of Safari's run and NN4.  However, I think that this code is perhaps safe.

Initial Title
Browser Checker

Initial Tags
browser

Initial Language
JavaScript