goulashsoup goulashsoup - 25 days ago 4x
Javascript Question

Javascript SyntaxError: illegal character in addEventListener line

I have following simple code (from here) and Firefox 49.0.1 says it has a Syntax Error in the last javascript line:

<!DOCTYPE html>
<meta charset="utf-8">
function doit(e) {
var eventType = e.type;
var files = e.target.files;
var reader = new FileReader();
reader.onload = function() {
var parsed = new DOMParser().parseFromString(this.result, "text/xml");

document.getElementById("selectfile").addEventListener("change", doit, false);​ // Syntax Error here.

<input type="file" id="selectfile" />

enter image description here

I really don´t have a clue whats wrong. I appreciate your help.


You have the illegal character U+200B after the semicolon on that line. It's a whitespace character, so you can't see it. Just backspace/delete it, and then type a normal space.

See: this JSFiddle highlights the bad character.