Long time no JS, a lot of things have forgotten. The recent use of JS stitching string encountered problems, no matter how the stitching in IE in the error, very depressed.
After a day, and picked up the code looked down, suddenly remembered in the Java concatenation string escape character, just think of JS also have this dongdong.
It turns out this way:
Copy Code code as follows:
TR + + "<td><a href= ' javascript:void (0); ' onclick= ' Confirmdeloneinfo (' +url2+ ' ', '" +obj.title+ '); ' > ';
In the editor is not an error, to the browser how to point onclick are not reflected, F12 on the error, looked at the script, the string completely changed
After modification:
Copy Code code as follows:
TR + + "<td><a href= ' javascript:void (0); ' onclick= ' Confirmdeloneinfo (\" "+url2+" \ ", \" "+obj.title+" \ "); ' > '
There's no problem.
Knowledge Summary:
The effect of single double quotes in JS is the same, but if you have a single quote in your string, you use double quotes outside, and if you have double quotes in your string, the outside is enclosed in single quotes, so you don't have to escape characters.
The output of the above result is:
Copy Code code as follows:
Onclick= ' Confirmdeloneinfo ("http://...?type=1&nodeId=11", "Test 1"); '
See in HTML, if the outside use of single quotes inside to use double quotes, or IE error, so use the escape character \ "" to convert double quotes. In the dynamic generation of HTML elements, pay particular attention to the issue of single double quotes, otherwise it will be a headache.
Oh, a little knowledge of the summary, welcome correction ....