Created
July 24, 2012 04:56
-
-
Save riix/3168110 to your computer and use it in GitHub Desktop.
Brower Detect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $ap = navigator.appVersion | |
var $ua = navigator.userAgent.toLowerCase (); | |
var browser = { | |
ie : $ap.indexOf('MSIE') != -1, | |
ie6 : $ap.indexOf('MSIE 6') != -1, | |
ie7 : $ap.indexOf('MSIE 7') != -1, | |
ie8 : $ap.indexOf('MSIE 8') != -1, | |
opera : !!window.opera, | |
safari : $ua.indexOf('safari') != -1, | |
safari3 : $ua.indexOf('applewebkit/5') != -1, | |
mac : $ua.indexOf('mac') != -1, | |
chrome : $ua.indexOf('chrome') != -1, | |
firefox : $ua.indexOf('firefox') != -1, | |
ipod : $ua.match(/ipod/), | |
ipad : $ua.match(/ipad/), | |
iphone : $ua.match(/iphone/) | |
} | |
var $ag_id = (browser.ipod||browser.ipad||browser.iphone); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://webknight-nz.blogspot.kr/2011/03/ie-9-detection-with-jquery.html | |
if(!$.support.htmlSerialize && !$.support.opacity){ | |
// IE6,7,8 code | |
} else { | |
// IE9 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _setBrowser(){ | |
var userAgent = navigator.userAgent.toLowerCase(); | |
// Figure out what browser is being used | |
jQuery.browser = { | |
version: (userAgent.match( /.+(?:rv|it|ra|ie|me|ve)[\/: ]([\d.]+)/ ) || [])[1], | |
chrome: /chrome/.test( userAgent ), | |
safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ), | |
opera: /opera/.test( userAgent ), | |
firefox: /firefox/.test( userAgent ), | |
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), | |
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ), | |
webkit: $.browser.webkit, | |
gecko: /[^like]{4} gecko/.test( userAgent ), | |
presto: /presto/.test( userAgent ), | |
xoom: /xoom/.test( userAgent ), | |
android: /android/.test( userAgent ), | |
androidVersion: (userAgent.match( /.+(?:android)[\/: ]([\d.]+)/ ) || [0,0])[1], | |
iphone: /iphone|ipod/.test( userAgent ), | |
iphoneVersion: (userAgent.match( /.+(?:iphone\ os)[\/: ]([\d_]+)/ ) || [0,0])[1].toString().split('_').join('.'), | |
ipad: /ipad/.test( userAgent ), | |
ipadVersion: (userAgent.match( /.+(?:cpu\ os)[\/: ]([\d_]+)/ ) || [0,0])[1].toString().split('_').join('.'), | |
blackberry: /blackberry/.test( userAgent ), | |
winMobile: /Windows\ Phone/.test( userAgent ), | |
winMobileVersion: (userAgent.match( /.+(?:windows\ phone\ os)[\/: ]([\d_]+)/ ) || [0,0])[1] | |
}; | |
jQuery.browser.mobile = ($.browser.iphone || $.browser.ipad || $.browser.android || $.browser.blackberry ); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment