I have the following:
<html>
<body>
<script type="text/javascript">
document.write('Hello\nWorld')
</script>
</body>
</html>
As you probably all know, \n doesn’t work and I have to use <br> instead. It won’t work either if I link to an external .js file. Here are my questions:
- Why doesn’t
\nwork? - Why does
<br>even work? Shouldn’t everything that’s inside the script tags be strictly JavaScript instead of a dirty mix between HTML and JS? - Is it possible to make
\nwork somehow? - I know
\tdoesn’t work either. Any other stuff that won’t work inside HTML files? - Unrelated question (I didn’t want to open a new question just for this): I installed Node.js to be able to try out JS scripts from inside vim but when I run this script I get the error "
documentis not defined". Same thing happens when I try from the REPL. Any ideas?
When searching for similar questions, all I got was that I should use <br> instead of \n.