why [removed] tag in js string is being validated

前端 未结 4 2090
深忆病人
深忆病人 2021-01-15 12:09

I have following page



    




        
4条回答
  •  无人及你
    2021-01-15 12:20

    HTML is parsed before and independent from Javascript. The current browser behavior is that, once an open tag 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.

提交回复
热议问题