Skip to content

Instantly share code, notes, and snippets.

@batako
Created September 11, 2012 08:04
Show Gist options
  • Save batako/3696801 to your computer and use it in GitHub Desktop.
Save batako/3696801 to your computer and use it in GitHub Desktop.
ブラウザ判定
function BROWSER(){
var userAgent = window.navigator.userAgent.toLowerCase();
var appVersion = window.navigator.appVersion.toLowerCase();
var BROWSER;
if (userAgent.indexOf("msie") > -1) {
if (appVersion.indexOf("msie 6.0") > -1) {
BROWSER = "IE6";
}
else if (appVersion.indexOf("msie 7.0") > -1) {
BROWSER = "IE7";
}
else if (appVersion.indexOf("msie 8.0") > -1) {
BROWSER = "IE8";
}
else if (appVersion.indexOf("msie 9.0") > -1) {
BROWSER = "IE9";
}
else {
BROWSER = "IE?";
}
}
else if (userAgent.indexOf("firefox") > -1) {
BROWSER = "Firefox";
}
else if (userAgent.indexOf("opera") > -1) {
BROWSER = "Opera";
}
else if (userAgent.indexOf("chrome") > -1) {
BROWSER = "Google Chrome";
}
else if (userAgent.indexOf("safari") > -1) {
BROWSER = "Safari";
}
else {
BROWSER = "Unknown";
}
return(BROWSER);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment