Reflections on a IE8 compatibility issue

Source: Internet
Author: User

Recently made a demand, the function is very simple, the user's coupon number read out, and then displayed to the "User Center". When the development is complete, other browsers are normal, but not on the IE8. And, after pressing F12, it can be loaded again.

First, looking for the front-end personnel, looked, did not find the reason, she suspected that the script conflict, but busy for a long while, or did not fix.

Next, change the browser and toss back and forth.

Finally, think about it, before adding this function, the data is also read like that, using AJAX to request background data, and then write to the page's designated label, then why do you add a similar data on it? So, alert the parameters before and after. Finally, the alert fails at the step of the iteration. But before the Console.log () code is possible, can it be the effect of this function? Sure enough, after removing Console.log (), resumed normal!

The code is as follows:

$ (document). Ready (function () {$.ajax ({url: "/ucenter/getaccountbyuserid.action", type: "POST", Success:function ( Data) {var json = eval (' (' + data + ') '); $.each (JSON, function (key, value) {if (Data! = "" && data! = NULL) {$ ("#e M_account "). HTML (" ¥ "+ (Value.account). toFixed (2)); $ (" #em_backCount "). HTML (" ¥ "+ (Value.backcount). toFixed (2)); $ (" #em_freezeBackCount "). HTML (" ¥ "+ (Value.freezebackcount). toFixed (2)); $ (" #em_freezeAccount "). HTML (" ¥ "+ ( Value.freezeaccount). toFixed (2));//Set coupon number var couponstr = "";//IE8 not supported! Console.log ("[Debug]couponcount:" + value.couponcount); if (Value.couponcount > 0) {couponstr = "<a href= '/ucenter /querycoupon.action ' style= ' color: #DD4F11 ' > ' +value.couponcount+ ' </a> ';} Else{couponstr = Value.couponcount;} $ ("#em_couponCount"). HTML (COUPONSTR);} });}});});

sentiment: Encounter abnormal, to clear the idea, then to take action. Since some of the previous data were read in the same way, why not add one? Besides adding similar code, what kind of code does it add? Isn't that Console.log ()? A very good positioning of a way of thinking, but toss it so long, too should not.

Note: IE8/IE9 must first press F12 to open IE Dev tools to access the console object.
If you use an environment that contains IE8/9, develop a good habit with if (window.console) {...} Wrap Console.log () action, should not IE8/9 think of as Chrome/firefox, thought always have window.console available.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Reflections on a IE8 compatibility issue

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.