Skip to content

Instantly share code, notes, and snippets.

@wtser
Created March 15, 2017 02:43
Show Gist options
  • Save wtser/6ec90187d82505f56cabd94812f41f02 to your computer and use it in GitHub Desktop.
Save wtser/6ec90187d82505f56cabd94812f41f02 to your computer and use it in GitHub Desktop.
<script >
var userAgent = navigator.userAgent;
var isOpera = userAgent.indexOf("Opera") > -1;
var isMaxthon = userAgent.indexOf("Maxthon") > -1 ;
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera ;
var isFF = userAgent.indexOf("Firefox") > -1 ;
var isSafari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") < 1 ;
var isChrome = userAgent.indexOf("Chrome") > -1 ;
var isIE5 = isIE55 = isIE6 = isIE7 = isIE8 = false;
if(isFF){document.write("当前浏览器是 Firefox");}
if(isMaxthon){document.write("当前浏览器是 傲游(webkit核心)");}
if(isOpera){document.write("当前浏览器是 Opera");}
if(isSafari){document.write("当前浏览器是 Safari");}
if(isChrome){document.write("当前浏览器是 Chrome");}
if(isIE){document.write("当前浏览器是 IE");}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment