0

When I try to visit this html file, the console gives the error "unexpected identifier".

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
    </head>
    <body>
        <script src="db.js" charset="UTF-8" type="text/javascript"></script>
    </body>
</html>

It gives an error on the first line of the js file. This is because that line contains greek characters. I have encoded both files in UTF-8.

I would really appreciate help!

EDIT: here's an example of the js file:
var items = [{word:"ὁ, ἡ, τό",meaning:"the"}]
But the array has more than nine hundred items like that.

Pieter Mantel
  • 123
  • 1
  • 9
Pieter Mantel
  • 15
  • 1
  • 5
  • 3
    We can't help you without seeing a *minimal* version of `db.js` that causes the problem; see: [mcve] *"This is because that line contains greek characters. I have encoded both files in UTF-8."* If so, and if your server is sending them with the correct `Content-Type` header (including charset), then greek characters are not a problem (provided they're in comments or strings, or the ones in identifiers are in the relevant unicode categories [ID start and ID continue]). – T.J. Crowder Oct 05 '18 at 12:53
  • It is more likely a 404 on the JS file giving error on the < of error page – mplungjan Oct 05 '18 at 12:56
  • Expanding on a part of my note above: The `charset` attribute of the `script` element isn't used if the server says what the charset is in the response headers. (I'm not sure it's ever used; [the spec](https://html.spec.whatwg.org/#the-script-element) doesn't list it.) – T.J. Crowder Oct 05 '18 at 13:05
  • I made a script to replace each of the characters with their `\uXXXX` counterparts. Thanks! – Pieter Mantel Oct 25 '18 at 08:24

0 Answers0