Skip to content

Instantly share code, notes, and snippets.

@haohcraft
Created December 19, 2014 13:41
Show Gist options
  • Save haohcraft/1919de6b44d594f1a8ef to your computer and use it in GitHub Desktop.
Save haohcraft/1919de6b44d594f1a8ef to your computer and use it in GitHub Desktop.
isFirefox/isWebkit/isSafari
'use strict';
function isFirefox() {
return /firefox/i.test(navigator.userAgent);
}
function isWebkit() {
return 'WebkitAppearance' in document.documentElement.style;
}
function isSafari() {
return !!window.safari;
}
if(navigator.appName.indexOf("Internet Explorer")!=-1){ //yeah, he's using IE
var badBrowser=(
navigator.appVersion.indexOf("MSIE 9")==-1 && //v9 is ok
navigator.appVersion.indexOf("MSIE 1")==-1 //v10, 11, 12, etc. is fine too
);
if(badBrowser){
// navigate to error page
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment