How to make a function run only in IE 10 and 11?

2

I want a code snippet (a specific function) to run only when the browser is IE 10 and 11, when it is Firefox or Chrome for example, I want this function to be ignored. Is this possible?

    
asked by anonymous 29.07.2017 / 16:23

1 answer

2

I would not do this, read this , but if you really want it (it will not work on Edge too):

if (/MSIE \d|Trident.*rv:/.test(navigator.userAgent)) {
    funcao()
}

I placed GitHub for future reference.

    
29.07.2017 / 16:43