Escape </ in script tag contents

后端 未结 4 1223
死守一世寂寞
死守一世寂寞 2021-01-01 19:26

In HTML, tags and entities aren\'t parsed within

4条回答
  •  既然无缘
    2021-01-01 20:11

    In HTML, as opposite to XHTML, the content of a script element is processed as plain text except for the occurrence of an end tag, so that ends processing and must, in conforming documents, start the end tag . There is no general mechanism to avoid this. Any methods that circumvent this feature are unavoidably dependent on the “language” used inside the element. The word “language” is in quotes here, because the content can be just about anything, as long as your code can parse and process it.

    So: no general mechanism, but for content other than JavaScript or some of the few other client-side scripting languages recognized by some browsers, you can make your own rules.

提交回复
热议问题