JavaScript Window print() Tutorial

In this section, we will learn what the window print() method is and how to use it in JavaScript.

JavaScript Window print() Method

Via the `print()` function, we can print the content of a webpage.

The function takes no argument and there’s no return value.

Simply call the function and the Print dialog box will appear on the browser so that the user can proceed to print the page.

Window print() Method Syntax:

print();

Window print() Method Parameter:

The method does not take an argument.

Window print() Method Return Value:

The method does not return a value.

Example: using Window print() method in JavaScript

See the Pen using Window print() method in JavaScript by Omid Dehghan (@odchan1) on CodePen.

Note: the `onclick` attribute is an event handler that will be explained in later sections.

In short, here if we click on the `Click to print` button, the Print window will appear and we can then print the page.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies