Debugging img’s onload() unexpected behavior

When I initially evaluated this lab, I googled around to see if anyone had this similar behavior. Interestingly, I did find a thread here.

Throughout the development of this lab, I noticed others were inserting the onload handler inline with the img tag, instead of implementing it at runtime via JavaScript (as requested). I ended up implementing the handler at runtime via JavaScript. I did notice the JavaScript had to be placed within the context in order for it to be able to resolve the specific HTML DOM element within .

Once implementing the onload handler at run-time, I noticed that following changing the src of the image, the onload handler would not fire. Initially I thought this was related to caching (as many others mentioned the same thing on various forums). But I ended up clearing caches and even went to the extend of adding GET parameters to the photo URL to work around potential caching issues. Unfortunately, it had not solved anything.

The standard behavior of the test across all browsers (FireFox, Opera, Chrome, Safari) seems to all replicate the same issue. There were odd times where FireFox did manage to properly load it on a cold-load, but following a refresh, replicated the behavior of the other browsers.

You can find my example here: https://st3v3n-d.github.io/html_img_onload_debug/

责编内容来自:DPS909 (源链) | 更多关于

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » Debugging img’s onload() unexpected behavior

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录