1. Preface
When doing front-end development, the company's specifications require customer-oriented compatibility to IE8, but in IE8 mode often find a variety of errors, such a method is undefined, does not support a property or object, etc., when using jquery, jquery is incompatible with IE8 from 2.0, with a minimum of support for IE9, so it is inherently compatible to introduce a lower jquery version.
2.IE8 does not support jquery version resolution
- Load the corresponding version of jquery by judging the version of IE browser
Use statement <!--[if IE 8]> IE8 recognizable <![ endif]--> code as follows:
1 <script type= "Text/javascript" src= "<%=path%>/js/jquery-3.1.1.min.js" ></script>2 <!--[if IE 8]>3 <script type= "Text/javascript" src= "<%=path%>/js/ Jquery-1.9.1.min.js "></script>4<![ Endif]-->
This way, when switching to IE8, the lower version of jquery overwrites the higher version of jquery. If you need to adjust the style of some elements under IE8, it's best to put the JS code at the bottom of the page (and notice if there are inline styles), otherwise the styles set for some dynamically loaded content may not take effect.
3.IE8 does not support foreach solutions
- To add a custom foreach method to a browser that does not support foreach
The code is as follows:
1 if (typeof Array.prototype.forEach! = ' function ') {2 Array.prototype.forEach = function (callback) {3 for (var i = 0; i < this.length; i++) {4 callback.apply (this, [this[i], I, this]); 5 }6 };7}
If the jquery plugin is introduced, you can place the code at the beginning of the plug-in's content so that the Foreach method under IE8 does not get an error.
jquery compatible Browser IE8 method