10
09/2014
conditionizr
conditionizr 蛮难用的。但浏览器检测办法还是可以学学
Chrome
conditionizr.add('chrome', [], function () { return !!window.chrome && !/opera|opr/i.test(navigator.userAgent); });
Safari
conditionizr.add('safari', [], function () { return /constructor/i.test(window.HTMLElement); });
Firefox
conditionizr.add('firefox', [], function () { return typeof InstallTrigger !== 'undefined'; });
Opera
conditionizr.add('opera', [], function () { return !!window.opera || /opera|opr/i.test(navigator.userAgent); });
IE 10
conditionizr.add('ie10', [], function () { var version = false; /*@cc_on if (/^10/.test(@_jscript_version) && /MSIE 10\.0(?!.*IEMobile)/i.test(navigator.userAgent)) version = true @*/ return version; });
IE 10 Touch
conditionizr.add('ie10touch', [], function () { return /MSIE 10\.0.*Touch(?!.*IEMobile)/i.test(navigator.userAgent); });
IE 9
conditionizr.add('ie9', [], function () { var version = false; /*@cc_on if (/^9/.test(@_jscript_version) && /MSIE 9\.0(?!.*IEMobile)/i.test(navigator.userAgent)) version = true @*/ return version; });
IE 8
conditionizr.add('ie8', [], function () { var version = false; /*@cc_on if (@_jscript_version > 5.7 && !/^(9|10)/.test(@_jscript_version)) version = true @*/ return version; });
IE 7
conditionizr.add('ie7', [], function () { var version = false; /*@cc_on if (@_jscript_version == 5.7 && window.XMLHttpRequest && /MSIE 7\.0(?!.*IEMobile)/i.test(navigator.userAgent)) version = true @*/ return version; });
IE 6
conditionizr.add('ie6', [], function () { var version = false; /*@cc_on if (@_jscript_version == 5.6 || (@_jscript_version == 5.7 && /MSIE 6\.0/i.test(navigator.userAgent))) version = true @*/ return version; });
Retina
conditionizr.add('retina', [], function () { return !!window.devicePixelRatio >= 1.5; });
Touch
conditionizr.add('touch', [], function () { return !!'ontouchstart' in window || !!navigator.msMaxTouchPoints; });
iOS
conditionizr.add('ios', [], function () { return /(iPad|iPhone|iPod)/i.test(navigator.userAgent); });
Windows Phone 8
conditionizr.add('winPhone8', [], function () { return /Windows Phone 8.0/i.test(navigator.userAgent); });
Windows Phone 7.5
conditionizr.add('winPhone75', [], function () { return /Windows Phone 7.5/i.test(navigator.userAgent); });
Windows Phone 7
conditionizr.add('winPhone7', [], function () { return /Windows Phone 7.0/i.test(navigator.userAgent); });
Mac
conditionizr.add('mac', [], function () { return /mac/i.test(navigator.platform); });
Windows
conditionizr.add('windows', [], function () { return /win/i.test(navigator.platform); });
Chromium
conditionizr.add('chromium', [], function () { return /cros i686/i.test(navigator.platform); });
Linux
conditionizr.add('linux', [], function () { return /linux/i.test(navigator.platform) && !/android|cros/i.test(navigator.userAgent); });