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>
精彩评论