asp.net.ph

Skip Navigation Links

print Method

DHTML Methods


Prints the document associated with the window.

Syntax

window.print ( ) 
Return Value

No return value.

Remarks

Calling the print method has the same effect as choosing Print from the Microsoft® Internet Explorer® File menu. The method, exposed off the window object, presents the print dialog for the user to OK or cancel. Pages cannot be printed without user acceptance from this dialog.

The onbeforeprint and onafterprint events are fired immediately before and after the document associated with the window is printed. These two events are particularly useful when not all the information on the page is visible at all times. The onbeforeprint event gives the Web author an opportunity to modify the document to make all the information on the page visible for printing purposes. The onafterprint event provides a means to revert the document back to its original state.

Example

This example lets an author call the window.print ( ) method which prompts the user to print the current page.

<input type=button value="Print me"
  onclick="window.print ( ) ">

Applies To

window



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

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