The following breaks due to the carriage return in the str variable, returning ‘unterminated string constant’ error. Problem is I cannot control the carriage returns as they are entered by an outside system.
Anyone know if a way to force JS to ignore the carriage returns? I need to swap out the <td> contents, currently using .innerHTML.
Thanks for any help.
Problem code:
<script>
var str = “<p><b>test with inner</b></p>
<p”;
var x = 1;
function inner() {
if (x > 0) {
document.getElementById(“overviewText”).innerHTML = str;
}
}
</script>
<table border=”1″>
<tr><td><a href=”#” onClick=”inner();”>click…</a></td></tr>
<tr>
<td>
<div id=”overviewText”></div>
</td>
</tr>
</table>