I've been trying some tricks in javascript and came to a ridiculous problem: I can't use <script>
as a substring in a javascript string! Here is an example:
<html>
<head>
<script>
alert("<script></script>");
</script>
</head>
</html>
It supposed to print out <script></script>
, but instead, I get this:
");
Printed out on the page, as HTML.
Question: How can I use <script>
followed by </script>
substrings in Javascript, and why is it acting that way?
Here is JSFiddle of it.
See Question&Answers more detail:os