Snandy
If You cannot hear the sound of the genuine in you, you'll all of the your life spend your days on the ends of strings that Somebody else pulls.
Three ways JavaScript determines whether a picture is loaded
Sometimes you need to get the size of the picture, which needs to be done after the picture is loaded. There are three ways to achieve this, as described below.
First, the Load event
<! DOCTYPE html> function () { = ' loaded ' } </script></body>
Test, all browsers show "loaded", indicating that all browsers support IMG's Load event.
Ii. ReadyStateChange Events<! DOCTYPE html> function () { if(img1.readystate== "Complete" | | img1.readystate== "Loaded") { = ' readystatechange:loaded ' } } </ Script></body>
ReadyState for complete and loaded indicates that the picture has been loaded. The test Ie6-ie10 supports this event and is not supported by other browsers.Third, the Complete property of img<! DOCTYPE html>functionimgload (IMG, callback) {varTimer = SetInterval (function() { if(Img.complete) {callback (IMG) clearinterval (timer)} }, 50)} imgload (IMG1,function() {p1.innerhtml (' Load complete ') }) </script></body>JS get the picture is loaded complete