I created a simple HTML file using TextEdit, set to plain text UTF-8 (on a Mid 2012 MacBook Pro, running Sierra). Markup as follows:
<html>
<head>
<title>Simple Page</title>
</head>
<body>
<p>This is a very simple HTML page</p>
<script src="script.js"></script>
</body>
</html>
The linked JavaScript file is in the same directory as the HTML document and is also written in TextEdit and contains:
alert(“Hello world”);
However, when I opened that local HTML file in several browsers none of them showed my pop-up despite the fact that pop-UPS ARE enabled in both browsers. So, upon that I inspected my code. The console error I'm getting is:
Uncaught SyntaxError: Invalid or unexpected token script.js:1
I found that my script had been interpreted as:
alert(“Hello worldâ€);
Which is obviously not what I wrote, so something is going wrong somewhere. I've spent hours trying to figure out why my code isn't being interpreted correctly. Can anyone tell me why my code file is ending up with such strange characters, and thus not running?