[removed] The best way to detect IE

前端 未结 3 934
礼貌的吻别
礼貌的吻别 2021-01-13 12:22

Reading this article I\'ve found a following piece of code:

if (\'v\'==\'\\v\') { // Note: IE listens on document
    document.attachEvent(\'onstorage\', onS         


        
3条回答
  •  迷失自我
    2021-01-13 13:04

    You can check for Trident, IE's engine, by the following:

    var trident = !!window.ActiveXObject;
    

    As stated on MSDN it is only supported in IE.

    Edit:

    Note: above code returns false in IE-11, If you want to detect also IE-11 use this:

    var isIE = "ActiveXObject" in window; //window.ActiveXObject !== undefined;
    

提交回复
热议问题