img.onerror does not seem to work for IE8

↘锁芯ラ 提交于 2019-12-01 10:35:23

Could it be that the page is already loaded by the time the img.onerror handler is executed, and IE doesn't rexecute the function for the dojo.addOnLoad(warningDialogFunc)?

Try changing

img.onerror = function() {
    dojo.addOnLoad(warningDialogFunc);
}

to simply:

img.onerror = function() {
  warningDialogFunc();
}

You have to set up the handler before you set the source of image, when you change the src attribute, IE will try to download the image and trigger the events.

var img = new Image();
img.onload = function() {
        window.open(userGuideUrl1);
}
img.onerror = function() {
    dojo.addOnLoad(warningDialogFunc);
}
img.src = userGuideUrl1_img + '?' + (new Date).getTime();  // Trigger image download and the handlers.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!