A
A
Andrey Savrasov2014-09-22 08:33:01
JavaScript
Andrey Savrasov, 2014-09-22 08:33:01

How to detect IE including 11?

It is necessary to determine in js that the user has logged in with IE. In this case, it is necessary that the method takes into account the 11th version. I don't need to define the version, just the fact itself. Anyone suggest a solution?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
F
Farid Shamsutdinov, 2014-09-22
@as3coder

var ua = window.navigator.userAgent.toLowerCase(),
is_ie = (/trident/gi).test(ua) || (/msie/gi).test(ua);

See userAgent. It's more correct to look for " Trident ", but for greater reliability, you can also check "MSIE".

R
Rrooom, 2014-09-22
@Rrooom

var is_ie = confirm('Are u use IE?')

E
Evgeny Petrov, 2014-09-22
@Petroveg

Conditional compilation
Branching variant:

/*@cc_on @if (@_jscript)
console.log('Я — осёл и мой номер ' + @_jscript_version);
@else @*/
document.write('Я — обычный современный утюг');
/*@end @*/

Well, only for IE:
/*@cc_on
console.log('Я — осёл и мой номер ' + @_jscript_version);
@*/

U
UbuRus, 2014-09-22
@UbuRus

Perhaps you do not need to determine the version of IE, but to determine what features the browser can do? Look at modernizr.com/.
And for IE older versions there are conditional comments: www.quirksmode.org/css/condcom.html
Well, specifically the answer to the question: stackoverflow.com/questions/13478303/correct-way-t...

S
Slava90, 2014-09-22
@Slava90

if (document.all) {
    // Код для всех версий IE. В других браузерах выполняться не будет.
}

1
1001001 111, 2014-09-22
@IgorO2

htmlbook.ru/samlayout/internet-explorer/uslovnye-k...
example:
jsfiddle.net/umcyyyc4/3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question