Skip to content Skip to sidebar Skip to footer

Ending Script Tag In Json Causing Chrome Parser Error

Gives parser error in Chrome. Escaping works ... https://jsfiddle.net/OndrejSpilka327/banr9836/ Is it really chrome bug? EDIT I don't think the argumentation is co

Solution 1:

No it’s not a Chrome bug. The HTML parser doesn’t know anything about JavaScript, it will close the <script> tag at the first occurrence of </script> that it finds. If that’s in the middle of a JavaScript program you end up with an invalid program.

Any character sequence that has a special meaning but should not interpreted with that special meaning needs to be escaped or split up.

See also Why split the <script> tag when writing it with document.write()?

Post a Comment for "Ending Script Tag In Json Causing Chrome Parser Error"