The line "</script>" raises an error in IE
If I add this html snippet to my page:
<script type="text/javascript">
var s = '</script>'
</script>
IE 7.0 shows syntax error (exclamation mark at bottom left): "Unterminated string constant"
If I only change one letter (any), the error goes away - it looks like IE doesn't like that particular word, including the brackets.
Any ideas why?
Thank you, Andrey
source to share
This will happen for any browser. The HTML parser does not know the details of the scripting language you are trying to use, so the tag <script>
will be aborted the first time it appears </script>
, regardless of context. The JS parser will then of course complain that the line is not completed because the closing apostrophe is not inside the script block.
You need to use something like instead '<\/script>'
if you want to use that line in your script.
source to share