JavaScript code is incompatible with IE because the comma is invalid.
When ExtJS is used for front-end development, it is found that the system can be normally displayed in Google's browser and Firefox. However, when opened in IE, an error is reported, such as Expected identified, string or number. Later, when checking the code, we found that the IE incompatibility was caused by the nonstandard comma in the js Code.
Since I use eclipse to write code, I will introduce how to use eclipse to solve this problem:
For example, there is the following piece of nonstandard code:
Ext. onReady (function () {var panel = Ext. create ('ext. container. viewport', {layout: 'border', items: [{title: 'North panel ', html: 'North content', region: 'north', height: 100 ,}, {title: 'West panel ', html: 'West content', region: 'west', width: 150, // Note 1}, {title: 'mainpanel ', html: 'main content', region: 'center',/* Note 2 */}]});
We can see that there is a comma (,) next to 100, 150, and center. If you run it with IE, an error will actually be reported. Now that the code has been written like this, how can this problem be detected!
Figure 1: File Search
As shown in 1, you can use the File Search function of eclipse to Search using regular expressions. The regular expression is \ s *}. However, this is a problem. You can only retrieve the first error. If you add // or/**/to annotate it, it cannot be detected. However, you can also use js Code compression tools such as yuicompressor to compress the code. When compressing the Code, all the comments will be removed, and then you can detect the compressed js file. Of course, you can also write algorithms for detection. However, this is still difficult for ordinary people!
However, another method I suggest is to use the plug-in. Here I use the Spket plug-in. The official website of Spket is.
Figure 2: Spket Detection
As shown in figure 2, we can find that Spket automatically detects code irregularities and marks out all the problems. I suggest using this method, this is because you can discover problems when writing code, which helps to write standardized and beautiful code! In other words, sometimes the compatibility is because the object used does not exist in IE. For example, the console object exists in Firefox and Google, but an error is returned when console.info is used in ie! So remember to remove some incompatible objects from the code!
The preceding section describes the incompatibility of IE caused by Invalid commas in JavaScript code. I hope this will be helpful to you!
Articles you may be interested in:
- Windows. parent is incompatible with Firefox when calling the parent framework
- Summary of Solutions to incompatibility between JavaScript on IE and Firefox
- Jquery achieves proportional scaling of images and max-width in ie.
- Solutions for incompatible JavaScript click events in IE8
- Solve the incompatibility problem of FCKEditor in IE10 and IE11.