asp.net.ph

Skip Navigation Links

onbeforeprint Event


Fires on the object just before its associated document prints.

Syntax

Inline <element onbeforeprint = "handler" ... >
Script object.onbeforeprint = handler

Remarks

Bubbles No
Cancels No
To invoke
  • Choose Print from the File menu in Internet Explorer.
  • Press CTRL + P.
  • Right-click anywhere on a page, and choose Print.
  • Right-click on a link on a page, and choose Print.
  • From Windows Explorer, select an .htm file and choose Print from the File menu.
  • From Windows Explorer, right-click on an .htm file and choose Print.
Default action Prints the document associated with the object for which the event is specified.

This event gives the Web author an opportunity to modify the document just before it prints; in most cases, to make all the information on the page visible just before printing.

The event is usually used in conjunction with the onafterprint event, which provides a means for the Web author to undo the changes made to the document in the onbeforeprint event.

Event Object Properties

Although event handlers in the document object model do not receive parameters directly, the handler can query the event object for data.

Event Object Properties


Example

The following example demonstrates how the onbeforeprint event can be used to make all currently hidden sections of the page visible just before the page prints. The onafterprint event is then processed, after the page prints, to revert the document back to its original state.

Sample Code


Applies To

window, BODY, FRAMESET

See Also

onafterprint, print


Need a break ?
Suggested Reading

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph.

If you have any question, comment or suggestion,
please send us a note