IE8 supports the function. bind () method, ie8function. bind
This bind method is only supported by the ie10 browser. If it is earlier than this version, an undefined error message is displayed. So I had to go online with the google solution again, but I had to pay close attention to it. We found a solution on the firefox development site, that is, adding the property prototype so that all browsers can support the bind method. The Code is as follows:
<script type="text/javascript">if (!Function.prototype.bind) { Function.prototype.bind = function (oThis) { if (typeof this !== "function") { throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); } var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function () {}, fBound = function () { return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); }; fNOP.prototype = this.prototype; fBound.prototype = new fNOP(); return fBound; }; } </script>
It mainly solves the bug of the example on the official Baidu MAP website and extracts the following code:
<! DOCTYPE html>
This attribute or method is not supported by JS and IE8 compatibility problem objects.
You can add compatibility information to the webpage header so that IE displays your webpage in the Compatibility View by default ,, for more information, see technet.microsoft.com/zh-cn/library/ff955640 (WS.10 ). aspx
IE8 does not support jquery's attr Solution
This is not a JQuery error. IE8 does not support directly modifying the src of the img label.
An alternative: Use JQuery's html () method to directly rewrite the img tag. Understand?