About the onload event of the Image object.
What you want to obtain is the width and height of the image. Therefore, the onload method is used. In addition, the remote image is obtained.
However, when IE displays the image for the second time, the onload method is always not used. Code:
Var img = new Image ();
Img. src = "loading.gif ";
Img. onload = function (){
Var iheight = img. height;
Var iwidth = img. width;
};
Later, I showed it to xiaoniu. I learned that img. src should be placed behind the onload method ..
Later, google discovered that many people had summarized such problems .. I am really a layman ..
Because the onload method is not triggered when IE loads the buffer data, the code in this event is ignored. FF triggers the onload method when loading the buffer data.
So.
In fact, there is another point, that is, when onload needs to make adaptive adjustments to the image, we find that we need to set img. src for the element again in onload... Otherwise, only remember the first image...
This cache zone is completely unknown .. Continue.