, the onload event of the image in IE7, 8 and Chrome is very strange when the page is loading. Sometimes it is not triggered at all, and sometimes it is triggered. If you perform an operation to change some elements, the operation result will be invalid."/> , the onload event of the image in IE7, 8 and Chrome is very strange when the page is loading. Sometimes it is not triggered at all, and sometimes it is triggered. If you perform an operation to change some elements, the operation result will be invalid.">

Home  >  Article  >  Web Front-end  >  Solution to image onload event triggering problem_javascript skills

Solution to image onload event triggering problem_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:03:561296browse

And it varies depending on the page size and even the location of the code.

Everything works fine under Firefox.

The solution is to change the value of the image src before onload is triggered, which is equivalent to having a temporary placeholder image at the beginning of the image. During the page loading process, use js to replace it with the actual required src. As long as each If src changes before the onload event is triggered, onload will behave normally.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn