Window onload and IMG onload events

Source: Internet
Author: User

Window onload and IMG onload events

Typically, Window.onload is executed after the DOM is loaded. IMG is the onload event that finishes loading the image and executes it, depending on whether the IMG SRC is loaded.


So, look at the following code:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 
Note: The top 6.png itself to find the picture to replace on.
The above code will not pop up 1 because window.onload already includes the onload of the picture, andthe onload of the picture is whether the src of the monitor img is loaded complete。 Remove the comment can pop up 1, not eject 1 of the possibility that your picture cannot be found, SCR did not load complete, so there is no popup 1.


PS:IMG onload events can also be used flexibly, such as some special business needs, can not append window.onload events, and consider using IMG onload event, such as loading a small picture, do hidden processing, inside call onload event.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.