开发者

html tidy and javascript regular expressions

When HTML Tidy see this HTML:

<script type="text/javascript">
    var left =  /</g
</script>
开发者_Python百科

It generates

<script type="text/javascript">
    var left =  /<\/g
</script>

which causes the run-time error: unterminated regular expression literal.

Is there a way to avoid this behavior? Thanks


Yes. Just avoid using </something in the script since it could confuse some browsers as closing tag. Use \x3c instead.

<script type="text/javascript">
    var left =  /\x3c/g
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜