Sectioning Content Elements in DOM
HTML Grouping and Sectioning Content Elements in DOM – Part 2
Foreword: In this part of the series I talk about HTML sectioning content elements in DOM.
By: Chrysanthus Date Published: 5 Aug 2015
All the sectioning content elements and elements that work with them use the HTMLElement interface. However, the body element has extra attributes, which are event attributes. I spend the rest of this tutorial talking about the body element event attributes.
An event is an occurrence based on time. The names of the body element events are: onunload, onafterprint, onbeforeprint, onbeforeunload, onhashchange, onmessage, onoffline, ononline, onpagehide, onpageshow, onpopstate, onstorage.
You type an event attribute in the same way that you type any other attribute in the start tag of the element. However, the value of an event attribute is an ECMAScript function call to a user-defined function that will handle the event.
The onunload Event
When you close a web page either by closing the browser or closing the window tab, the page unloads from memory; that is an unload event. onunload means on-unload. This event is triggered when the web page unloads. Assume that you have the body start tag as,
and in the ECMAScript you have
alert('do some house keeping');
when the page unloads, the alert box should display, 'do some house keeping'.
Now, the major browsers have not yet implemented the body event attributes; so I will stop here and come back to add the tutorial, later.
Related LinksDOM Basics for HTML
DOM Event Basics for HTML
HTML Text and Other Elements in DOM
HTML Grouping and Sectioning Content Elements in DOM
DOM and HTML Embedded Content
HTML Canvas 2D Context
More Related Links
PurePerl MySQL API
Major in Website Design
Web Development Course
Producing a Pure Perl Library