<script type="text/javascript">
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //test for MSIE x.x;
var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
if (ieversion>=8)
document.write("You're using IE8 or above")
else if (ieversion>=7)
document.write("You're using IE7.x")
else if (ieversion>=6)
document.write("You're using IE6.x")
else if (ieversion>=5)
document.write("You're using IE5.x")
}
else
document.write("n/a")
</script>
Detect Internet Explorer
Chris Coyier
on
Sniffing user agent is not a “safe” solution.
I prefer the Dean Edwards one:
var isMSIE = /*@[email protected]*/false;
(More here: http://dean.edwards.name/weblog/2007/03/sniff/ )
Conditional compilation was removed in IE11
Or simply use what has already been built and not rewrite it:
if ($.browser.ie) { … }
$.browser is no longer supported by JQuery
using conditional comments is a lot easier, is’nt it?
The problem with conditional comments is that IE 10 no longer supports them
but conditional comments is not working in ie 10
this code does not work for IE11, can you modify the MSIE to detect IE11 also, Please help.
You can try this:
Thanks! document.documentMode works great!! :)
Np! :)
Nice work Nicola. I didn’t know this was a specific IE property: http://www.w3schools.com/jsref/prop_doc_documentmode.asp
can you provide it for css?