I have following page
HTML is parsed before and independent from Javascript. The current browser behavior is that, once an open tag is found, the browser will switch to "Script Data State" and interpret all following data as script until a is found.
Where the is detected doesn't matter — inside a JS string, a JS comment, a CDATA section, or even HTML comment.
You need to make the string does not look like to the HTML parser. The simplest way is to write <\/script> as in @Daniel's answer.