When using jquery’s html() method, sometimes the html code added inside contains some special characters and needs to be escaped.
The following example:
inst_html = "<a style=color:white' onmouseover = '"; inst_html += "javascript:showme('"+inst.instId+"_"+valId+"');"; inst_html += "' "; $("#inst_div_"+valId).html(inst_html);
If you write it directly like this, there will be no problem under chrome and FF browsers, but an error will be reported under IE8.
The solution is to change 'escape' in javascript to ', so that no error will be reported.
The above example is changed to:
inst_html = "<a style=color:white' onmouseover = '"; inst_html += "javascript:showme('"+inst.instId+"_"+valId+"');"; inst_html += "' "; $("#inst_div_"+valId).html(inst_html);
Some characters are escaped as follows:
•& symbol: "&", "&"
•Double quotes: """, """
•Less-than symbol: "<", "