JavaScript compatibility and debugging skills about javaspt PT compatibility, the lazy way is to use jQuery's tool functions. Do not use functions such as ECMAScript, because many browsers will report function failures. The following lists some javascript problems encountered during development.
1. Multiple commas (,) in the parameter list.
$. I am very familiar with ajax ({}) method, but I should note that in IE, if you add a comma to the last part of the parameter list while splicing, there is no doubt, all JS files in IE are invalid.
The following error is reported during debugging:
The identifier, string, or number is missing.
Data: {S_Id: Subject_Id, level: $ ("# addKey"). attr ("lang"), -- if this comma is entered, IE will report an error, Firefox Google will be normal .},
2. Differences between var str and var str = ""
《script》var Str1;for (var i = 0; i < 3; i++){ Str1 += "xxx"}alert(Str1);var Str2 = "";for (var i = 0; i < 3; i++){Str2 += "xxx"}alert(Str2);《script》
The two output results are as follows:
First time:
A variable. If no value is assigned during definition, it is undefined. Add the undefined + "string to be added ". In this case, assign a value to the HTML element. Undefined is also displayed. How do you know it.
3. debugging of IE cache JS
During debugging today, we found that IE8's JS cache is very domineering. Refreshing and clearing the cache are invalid. The left mouse button is almost broken, but it is still not refreshed.
Now, a special trick is to add a new Date () to the end when introducing JS (). In this way, you don't have to refresh it so hard.