Reputation: 1785
I'm getting the following error: SyntaxError: unterminated string literal.
Seems like there is a problem with the first data +=
command. What is wrong with it? I don't break any line.
// Data
var data = "<!doctype html><html><head>";
data += "<script type='text/javascript' src='test1.js'></script>";
data += "</head><body>TEST</body></html>";
Upvotes: 2
Views: 76
Reputation: 413826
You can't include the sequence of characters </script>
in a script block. The HTML parser assumes that it ends the block.
The typical way of handling that is something like
data += "<script type='text/javascript' src='test1.js'></" + "script>";
The HTML parser does not understand JavaScript syntax. When it sees <script>
, it just does a blind search through subsequent content looking for </script>
.
Upvotes: 3