Thursday, September 3, 2015

[JavaScript] 判斷使用者是否使用 IE 瀏覽器

var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if(msie > 0) {
  alert("This is IE.");
}
else  if(!!navigator.userAgent.match(/Trident.*rv\:11\./)) {
  alert("This is IE11.");
}
else {
  alert("Others.");
}

No comments:

Post a Comment