Recently used JS stitching string encountered problems, no matter how the stitching in IE in the error, so found a good solution, here with you to share the following
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 to look at, suddenly remembered in Java stitching string escape characters, just think of JS also have this dongdong. It turns out this: code is as follows: TR = "<td><a href= ' javascript:void (0); ' onclick= ' Confirmdeloneinfo ('" + url2+ "', '" "+obj.title+"); ' ><img src= ' images/tab/010.gif '/> '; in the editor is not an error, to the browser how to point the onclick are not reflected, F12 the error, looked at the script, the string completely changed modified: code as follows: TR = "<td><a href= ' javascript:void (0); ' onclick= ' Confirmdeloneinfo (" "+ url2+ "", "" +obj.title+ ""); ' ><img src= ' images/tab/010.gif '/> ' no problem. Knowledge Summary: The effect of single and double quotes in JS is the same, but if you have single quotes 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 above is: 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, otherwise IE error, so use the escape character "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 ....