JavaScript triggers document events and window events

Source: Internet
Author: User

Reprint Please specify source: http://www.uphtm.com/js/128.html

The browser window itself understands some events, including events that are triggered when a page is loaded, and events that are triggered when a visitor leaves the page:

load. When the Web browser finishes downloading the entire contents of the Web page file (the HTML file itself, plus any linked images, flash movies, and external CSS and JavaScript files), the Load event is triggered. Web designers are accustomed to using this event to start any program that operates a Web page. However, loading a Web page and all of its files can take a long time if you have a lot of graphics or other large linked files. In some cases, this means that the JavaScript program is not yet running after the page has been displayed in the browser for quite some time. Fortunately, jquery provides a much better alternative to the load event.

Resize. The browser triggers the Resize event when we resize the browser window by clicking the Maximize button or by dragging the browser's sizing pointer. When visitors change the size of their browser window, some designers use this event to change the layout of the page. For example, after the visitor resizes the browser window, you can see the width of the browser, and if it does widen, you can change the design to add more columns of content to fill the space.

Note: When resizing the window, Internet Explorer, opera, and Safari trigger multiple resize events, and Firefox only triggers the Resize event after the resize pointer has been released.

Scroll. The scroll event is triggered when the scroll bar is dragged, or when the Web page is scrolled using the keyboard (up/down/home/end, etc.) or the mouse wheel. If the page does not have a scroll bar, the scroll event is not triggered. Some programmers use this event to help figure out where the element appears on the screen (after the page scrolls).

unload. The Web browser triggers the Unload event when you click a link to another page, close a browser tab, or close a browser window. It is like the last gasp of a JavaScript program and gives us a chance to complete the last operation before the browser leaves the page. A malicious programmer once used this event to make it difficult for visitors to leave the page. Each time a visitor tries to close the page, a new window appears and returns to the page. However, you can also use this event to do some good things. For example, a program can warn a visitor that he has already started filling out a form but has not yet submitted it, or that the program can send form data to the Web server to save the data before the visitor exits the page.

Text: JavaScript triggers document events and window events, reproduced please specify the source: http://www.uphtm.com/js/128.html

JavaScript triggers document events and window events

Related Article

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.