IE 11中userAgent已經不包含
'msie'
所以用
'msie'
不能判斷IE 11
IE 11的userAgent版本為Trident x.x
判斷IE 11 用正則判斷userAgent中有沒有帶Trident字樣的字符串即可
var u = window.navigator.userAgent.toLocaleLowerCase(), ie11 = /(trident)\/([\d.]+)/, b = u.match(ie11); if(b){ alert("該瀏覽器是ie11"); }