How to Use the console in IE

Source: Internet
Author: User

How to Use the console in IE

Problem Source: I recently studied easyui. The video tutorial I watched was Sun Yu's EASYUI getting started video tutorial (Click here to download), which mentioned the console.info () method, today, I happened to encounter a program written by a colleague that is incompatible with IE, or is not compatible with IE 9 and earlier browsers, but runs well in google and Firefox. The Code is as follows:

 1    onBeforeLoad: function (row, param) { 2              if (row) { 3               console.info(row.cenCi); 4               if(row.cenCi==0){ 5                $(this).treegrid('options').url = *************************************; 6               }else if(row.cenCi==1){ 7                 if(row.isInject){ 8 //                 alert("Inject"); 9                  $(this).treegrid('options').url = *********************************;10                 }else{11 //                 alert("CITY-SRM");12                  $(this).treegrid('options').url = ***********************************;13                 }14                 15               }16               17              } else{18                $(this).treegrid('options').url = ***************************;19              }20          }

 

This is a method of treeGrid. After clicking it, it loads the subnode of a Certain Row, but this part of the code is used, and there is a problem in IE9 or earlier versions.

Problem description: each time you open the page in IE9, click the node, and the node does not respond. Then, F12, console debugging, and click again. The problem disappears .... Click again and you will find that you can click it to open it. It is okay to close the console, but each time you open the browser again, there will be a problem described.

Solution: At first, I thought it was an onBeforeLoad problem. This method also had different support in different browsers, but later I found that even if I modified other methods, the results would be the same, then I began to doubt about the console. In fact, Sun Yu's course clearly stated that console.info () will go wrong in IE, but after Baidu, I found that IE has supported the console method since IE8. For more information, see here. But why did Sun Yu say that IE has an error? Is it just the version earlier than IE8? I have carefully read the specific explanation of the MSDN window. console. One of these statements is as follows,

I suddenly realized that console.info () was supported only once after the console was opened, or I should not directly write lele.info () in IE.

The final code should be like this.

If (window. console) {console.info (row. cenCi );
}

In fact, the best habit is to delete this sentence directly after debugging! Release clean code!

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.