There are a lot of online to determine whether the picture has been loaded, but some of the browser is not suitable, the following small series to share some about JavaScript to determine whether the picture has been loaded method rollup, the specific content as follows:
I. OnLoad incident
By listening to the OnLoad event of the picture, you can determine whether the picture has been loaded, compatible with all browsers (the recommended method of the consortium), and the code example below
Two. Determine the complete property of an IMG object (DOM)
When the IMG load completes, the complete object property becomes true and the code example is as follows:
The method can also be compatible with all browsers.
Three. The onReadyStateChange incident
Under IE, the IMG object has the same onreadystatechange event as the Xhr object, which can pass Guo Jianting the event to determine whether the picture is loaded or not, and the code example is as follows:
This method is only available under IE