I have a js file and would like to run some code only if the browser is IE 8. Is there a way I can do this?
Right now I only have this but it's for all ie browsers:
if ($.browser.msie) {
//do stuff for IE 8
}
I have a js file and would like to run some code only if the browser is IE 8. Is there a way I can do this?
Right now I only have this but it's for all ie browsers:
if ($.browser.msie) {
//do stuff for IE 8
}
Alright people, I solved it myself like this:
Browser specific code is almost never a good idea. However, if you must do this, you can put your code inside conditional comments.
http://www.positioniseverything.net/articles/cc-plus.html
You can do it with conditional comments (by https://stackoverflow.com/a/10965091/1878731):
Or without messing with html (by http://en.wikipedia.org/wiki/Conditional_comment):
You can use the document.documentMode to get the version of IE.
For documentation refer here
Could you do a call in the header to redirect the page if it is less than IE9? I find myself doing this often for my clients that use a mixture of IE6-10.
In the document head I call,
The other option you could look into is a shim or polyfil. There are many on the internet that help bridge the gap between modern web design and older browsers. An example is Modernizr.
$.browser is deprecated so you can not use this object property in new jQuery version so to support this you have to use the jQuery migrate plugin.Here is the link. https://github.com/jquery/jquery-migrate/#readme