1
I need to do a browser check to know if it is Internet Explorer and if it is smaller than version 10.
How to do?
PS: My idea is to tell the user if you are using a version less than 10 that downloads a more current browser.
1
I need to do a browser check to know if it is Internet Explorer and if it is smaller than version 10.
How to do?
PS: My idea is to tell the user if you are using a version less than 10 that downloads a more current browser.
3
Internet Explorer is owned by document
that gives it. It’s the documentMode
.
Test this code:
alert(document.documentMode); // dá o numero da versão do IE
However, and as the bfavaretto referred to it is best to rely on "Feature Detection", detect functionalities, as this is more reliable.
A good example was when version 11 of IE came out they decided to change the UA string and everyone had problems with it.
Here is an interesting link with more alternatives: http://tanalin.com/en/articles/ie-version-js/
If you want to detect within HTML (without Javascript) you can use code comments that only IE detects. For example:
<!--[if lte IE 7]><script>
ie = 7;
</script><![endif]-->
lte
means IE<=7, only lt
means IE<7
2
Another way is to check the existence of some objects and combine some checks.
The following table contains the ready-to-use conditions.
Versões do IE Verificar condição
10+ document.all
9+ document.all &&! Window.atob
8+ document.all &&! Document.addEventListener
7+ document.all &&! Document.querySelector
6+ document.all &&! Window.XMLHttpRequest
5.x document.all &&! Document.compatMode
In the following example the condition is true if the browser is IE11+ or not.
if (!document.all) {
alert('Voce utiliza o IE11+ ou um outro navegador');
}
This works with mobile IE/Windows RT too?
Browser other questions tagged javascript jquery html browser
You are not signed in. Login or sign up in order to post.
Usually this is not a good idea, it is better to check if a specific functionality is available than to check which browser. Of course there are always exceptions, but I don’t know what would be the case here.
– bfavaretto
If you really want to arrive check if in the user agent string the last number is less than 6.0
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)
– Mansueli