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. therefore, the onload used by img in UBB code is used to handle large images for self-adaptation. 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 wrote a simple piece of code using JS.
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.