IE8 supports the function. bind () method, ie8function. bind

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.