开发者

addEventListener with inexplicable undefined method error

开发者 https://www.devze.com 2023-04-07 01:08 出处:网络
I couldn\'t find an answer to th开发者_运维百科is problem I\'ve been having. function UploadBar() {

I couldn't find an answer to th开发者_运维百科is 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?


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') };  
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号