正文开始 (function(jQuery){ <br /> <br /> if(jQuery.browser) return; <br /> <br /> jQuery.browser = {}; <br /> jQuery.browser.mozilla = false; <br /> jQuery.browser.webkit = false; <br /> jQuery.browser.opera = false; <br /> jQuery.browser.msie = false; <br /> <br /> var nAgt = navigator.userAgent; <br /> jQuery.browser.name = navigator.appName; <br /> jQuery.browser.fullVersion = ''+parseFloat(navigator.appVersion); <br /> jQuery.browser.majorVersion = parseInt(navigator.appVersion,10); <br /> var nameOffset,verOffset,ix; <br /> <br /> // In Opera, the true version is after "Opera" or after "Version" <br /> if ((verOffset=nAgt.indexOf("Opera"))!=-1) { <br /> jQuery.browser.opera = true; <br /> jQuery.browser.name = "Opera"; <br /> jQuery.browser.fullVersion = nAgt.substring(verOffset+6); <br /> if ((verOffset=nAgt.indexOf("Version"))!=-1) <br /> jQuery.browser.fullVersion = nAgt.substring(verOffset+8); <br /> } <br /> // In MSIE, the true version is after "MSIE" in userAgent <br /> else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) { <br /> jQuery.browser.msie = true; <br /> jQuery.browser.name = "Microsoft Internet Explorer"; <br /> jQuery.browser.fullVersion = nAgt.substring(verOffset+5); <br /> } <br /> // In Chrome, the true version is after "Chrome" <br /> else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) { <br /> jQuery.browser.webkit = true; <br /> jQuery.browser.name = "Chrome"; <br /> jQuery.browser.fullVersion = nAgt.substring(verOffset+7); <br /> } <br /> // In Safari, the true version is after "Safari" or after "Version" <br /> else if ((verOffset=nAgt.indexOf("Safari"))!=-1) { <br /> jQuery.browser.webkit = true; <br /> jQuery.browser.name = "Safari"; <br /> jQuery.browser.fullVersion = nAgt.substring(verOffset+7); <br /> if ((verOffset=nAgt.indexOf("Version"))!=-1) <br /> jQuery.browser.fullVersion = nAgt.substring(verOffset+8); <br /> } <br /> // In Firefox, the true version is after "Firefox" <br /> else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) { <br /> jQuery.browser.mozilla = true; <br /> jQuery.browser.name = "Firefox"; <br /> jQuery.browser.fullVersion = nAgt.substring(verOffset+8); <br /> } <br /> // In most other browsers, "name/version" is at the end of userAgent <br /> else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < <br /> (verOffset=nAgt.lastIndexOf('/')) ) <br /> { <br /> jQuery.browser.name = nAgt.substring(nameOffset,verOffset); <br /> jQuery.browser.fullVersion = nAgt.substring(verOffset+1); <br /> if (jQuery.browser.name.toLowerCase()==jQuery.browser.name.toUpperCase()) { <br /> jQuery.browser.name = navigator.appName; <br /> } <br /> } <br /> // trim the fullVersion string at semicolon/space if present <br /> if ((ix=jQuery.browser.fullVersion.indexOf(";"))!=-1) <br /> jQuery.browser.fullVersion=jQuery.browser.fullVersion.substring(0,ix); <br /> if ((ix=jQuery.browser.fullVersion.indexOf(" "))!=-1) <br /> jQuery.browser.fullVersion=jQuery.browser.fullVersion.substring(0,ix); <br /> <br /> jQuery.browser.majorVersion = parseInt(''+jQuery.browser.fullVersion,10); <br /> if (isNaN(jQuery.browser.majorVersion)) { <br /> jQuery.browser.fullVersion = ''+parseFloat(navigator.appVersion); <br /> jQuery.browser.majorVersion = parseInt(navigator.appVersion,10); <br /> } <br /> jQuery.browser.version = jQuery.browser.majorVersion; <br /> })(jQuery); <br />
正文结束 |
js 正则替换返回值做回调函数 | Bootstrap鼠标经过显示菜单的方法 |