The IMG does not support the onload tag. What should I do? I remember someone asked me before, but I didn't pay attention to this yet. now we finally have this problem. because the IMG tag does not have an onload event. so UBB CodeThe onload used by IMG in processing large images is adaptive, so this method cannot be used.
However, after testing, the body can still carry the onload event, so the solution is to process too large images after all the pages are loaded.
So I used js to write a simple code related code function reimgsize (){
For (j = 0; j <document. Images. length; j ++)
{
Document. Images [J]. width = (document. Images [J]. width> 420 )? "420": Document. Images [J]. width;
}
}
Add onload = "reimgsize ()" to the body.
Tested on Mozilla and IE.
Here, we will add about image self-adaptation. Mozilla is doing better than IE, because CSS can be used to control image self-adaptation.
We all know that Mozilla supports a max-width CSS syntax. Therefore, we define the global style of the image in this way.
Related code IMG {
Max-width: 100%; Height: auto;
}
In this way, the image automatically adapts to its size in the Div or table.