Check if IE8 supports pure Javascript

I used this to check:

$.browser.msie && $.browser.version == 8

But it seems that it has $.browserbeen removed from later versions of jQuery,

So,

How can I check this with just pure javascript?

I tried:

isIE8: navigator.appVersion.indexOf("MSIE 8") > 0

It seems to be done, but it doesn't look so good and actually looks like it has a lot of flaws ...

What is better aproach?

+4
source share
2 answers

This is longer than you want, but safer than parsing the UA string, as it is based on actual behavior (conditional IE comments): https://gist.github.com/paulirish/357741

+3
source

, SVG. SVG IE8 → http://caniuse.com/#search=svg DATA IE8 → http://caniuse.com/#search=data

:

if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) {
   if (!document.createElement('SVG').getAttributeNS) {
       if (document.createElement('DATA').getAttributeNS) {
           //the browser is defently IE8
        }
    }
}
+2

Source: https://habr.com/ru/post/1527518/


All Articles