Bowser by lance dikson-4,065★s-最后更新2019年10月2日-4.8KB
var result = bowser.getParser(window.navigator.userAgent);console.log(result);document.write("You are using " + result.parsedResult.browser.name +" v" + result.parsedResult.browser.version +" on " + result.parsedResult.os.name);
Detect.js(存档) by dar的arke-522★s-最后更新Oct 26,2015-2.9KB
var result = detect.parse(navigator.userAgent);console.log(result);document.write("You are using " + result.browser.family +" v" + result.browser.version +" on " + result.os.family);
Modernizr - 23,397★s - Last updated Jan 12, 2019 - To feed a fed horse, feature detection should drive any canIuse style questions. Browser detection is really just for providing customized images, download files, or instructions for individual browsers.
var OSName="Unknown OS";if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";if (navigator.appVersion.indexOf("Linux x86_64")!=-1) OSName="Ubuntu";
var nVer = navigator.appVersion;var nAgt = navigator.userAgent;var browserName = navigator.appName;var fullVersion = ''+parseFloat(navigator.appVersion);var majorVersion = parseInt(navigator.appVersion,10);var nameOffset,verOffset,ix;
// In Opera, the true version is after "Opera" or after "Version"if ((verOffset=nAgt.indexOf("Opera"))!=-1) {browserName = "Opera";fullVersion = nAgt.substring(verOffset+6);if ((verOffset=nAgt.indexOf("Version"))!=-1)fullVersion = nAgt.substring(verOffset+8);}// In MSIE, the true version is after "MSIE" in userAgentelse if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {browserName = "Microsoft Internet Explorer";fullVersion = nAgt.substring(verOffset+5);}// In Chrome, the true version is after "Chrome"else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {browserName = "Chrome";fullVersion = nAgt.substring(verOffset+7);}// In Safari, the true version is after "Safari" or after "Version"else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {browserName = "Safari";fullVersion = nAgt.substring(verOffset+7);if ((verOffset=nAgt.indexOf("Version"))!=-1)fullVersion = nAgt.substring(verOffset+8);}// In Firefox, the true version is after "Firefox"else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {browserName = "Firefox";fullVersion = nAgt.substring(verOffset+8);}// In most other browsers, "name/version" is at the end of userAgentelse if ( (nameOffset=nAgt.lastIndexOf(' ')+1) <(verOffset=nAgt.lastIndexOf('/')) ){browserName = nAgt.substring(nameOffset,verOffset);fullVersion = nAgt.substring(verOffset+1);if (browserName.toLowerCase()==browserName.toUpperCase()) {browserName = navigator.appName;}}// trim the fullVersion string at semicolon/space if presentif ((ix=fullVersion.indexOf(";"))!=-1)fullVersion=fullVersion.substring(0,ix);if ((ix=fullVersion.indexOf(" "))!=-1)fullVersion=fullVersion.substring(0,ix);
majorVersion = parseInt(''+fullVersion,10);if (isNaN(majorVersion)) {fullVersion = ''+parseFloat(navigator.appVersion);majorVersion = parseInt(navigator.appVersion,10);}
document.write(''+'Hey! i see you\'re using '+browserName+'! <br>'+'The full version of it is '+fullVersion+'. <br>'+'Your major version is '+majorVersion+', <br>'+'And your "navigator.appName" is '+navigator.appName+'. <br>'+'Your "navigator.userAgent" is '+navigator.userAgent+'. <br>')
document.write('And, your OS is '+OSName+'. <br>');