问题
I couldn't find an answer to this problem I've been having.
function UploadBar() {
this.reader = new FileReader();
this.reader.addEventListener(
"onloadstart"
, function(evt) {alert("Hello World");}
, false
);
}
when I try to run this code it gives me an undefined_method_error in the javascript debugger in chrome. Could anyone be so kind as to tell me what is wrong here?
回答1:
reader
is not an element, so don't use .addEventListener
Instead do the following.
function UploadBar() {
this.reader = new FileReader();
this.reader.onloadstart = function(e) { alert('Hello World') };
}
来源:https://stackoverflow.com/questions/7542538/addeventlistener-with-inexplicable-undefined-method-error