, 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
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.