jQuery1.6.2の$.supportでブラウザ判別

jQuery1.5あたりから$.supportの値が変わるらしいので調べてみた。(2011.7.28時点)

property Your Result Chrome12 Android Mobile Safari5.1 Opera11.50 Firefox3.6 Firefox5 IE6 IE7 IE8 IE9
ajax undefined true true true true true true true true true true
boxModel※1 undefined true true true true true true true true true true
changeBubbles undefined true true true true true true false false false true
checkClone※2 undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined
checkOn undefined false false false true true true true true true true
cors undefined true true true false true true false false false false
cssFloat undefined true true true true true true false false false true
hrefNormalized undefined true true true true true true false false true true
htmlSerialize undefined true true true true true true false false false true
leadingWhitespace undefined true true true true true true false false false true
noCloneChecked undefined true true true true true true false false false false
noCloneEvent undefined true true true true true true false false false true
opacity undefined true true true true true true false false false true
optDisabled undefined true false true true true true true true true true
optSelected undefined true true true true true true false false false false
scriptEval※2 undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined undefined
style undefined true true true true true true false false false true
submitBubbles undefined true true true true true true false false false true
tbody undefined true true true true true true false false true true

Demonstration

サンプルソースコード

/**
 * $.supportでブラウザの判別(jQuery1.6.2)
 *
 *
 */

var DETECT_APP = DETECT_APP || {};

DETECT_APP.util = {};

DETECT_APP.util.browser = (function () {
	var
		_isIE = false,
		_isIE6 = false,
		_isIE7 = false,
		_isIE8 = false,
		_isIE9 = false,
		_isFirefox = false,
		_isWebKit = false,
		_isSafari = false,
		_isChrome = false,
		_isOpera = false;

	function isIE () {
		return _isIE;
	}

	function isIE6 () {
		return _isIE6;
	}

	function isIE7 () {
		return _isIE7;
	}

	function isIE8 () {
		return _isIE8;
	}

	function isIE9 () {
		return _isIE9;
	}

	function isFirefox () {
		return _isFirefox;
	}

	function isWebKit () {
		return _isWebKit;
	}

	function isSafari () {
		return _isSafari;
	}

	function isChrome () {
		return _isChrome;
	}

	function isOpera () {
		return _isOpera;
	}

	//ブラウザ検出
	if(jQuery.support.noCloneChecked) {
		if(!jQuery.support.checkOn) {
			//WebKit
			_isWebKit = true;
			if(navigator.vendor.match(/apple/i)) {
				_isSafari = true;
			}
			else if(navigator.vendor.match(/google/i)) {
				_isChrome = true;
			}
		}
		else if(jQuery.support.cors) {
			_isFirefox = true;
		}
		else {
			_isOpera = true;
		}
	}
	else {
		//IE
		_isIE = true;
		if(jQuery.support.cssFloat) {
			_isIE9 = true;
		}
		else if(jQuery.support.tbody) {
			_isIE8 = true;
		}
		else if (typeof document.documentElement.style.maxHeight != "undefined") {
			_isIE7 = true;
		}
		else {
			_isIE6 = true;
		}
	}

	//公開するメソッド
	return {
		isIE: isIE,
		isIE6: isIE6,
		isIE7: isIE7,
		isIE8: isIE8,
		isIE9: isIE9,
		isFirefox: isFirefox,
		isWebKit: isWebKit,
		isSafari: isSafari,
		isChrome: isChrome,
		isOpera: isOpera
	};
}());

$(function () {
	var browser = DETECT_APP.util.browser;

	alert([
		"isIE: " + browser.isIE(),
		"isIE6: " + browser.isIE6(),
		"isIE7: " + browser.isIE7(),
		"isIE8: " + browser.isIE8(),
		"isIE9: " + browser.isIE9(),
		"isFirefox: " + browser.isFirefox(),
		"isWebKit: " + browser.isWebKit(),
		"isSafari: " + browser.isSafari(),
		"isChrome: " + browser.isChrome(),
		"isOpera: " + browser.isOpera()
	].join("\r\n"));
});