addEventListener with inexplicable undefined method error

旧巷老猫 提交于 2019-12-07 15:06:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!