Categories
JavaScript Answers

How to auto start print HTML page using JavaScript?

Spread the love

Sometimes, we want to auto start print HTML page using JavaScript.

In this article, we’ll look at how to auto start print HTML page using JavaScript.

How to auto start print HTML page using JavaScript?

To auto start print HTML page using JavaScript, we call print when the page is loaded.

For instance, we write

window.onload = () => {
  window.print();
};

to set window.onload to a function that’s called when the page finishes loading.

In it, we call window.print to open the print dialog.

Conclusion

To auto start print HTML page using JavaScript, we call print when the page is loaded.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *