Hello, in this JavaScript video, I am going to show you how to trigger the print method. So if you go to like Chrome or Firefox to do click Print, you know, this little thing gets triggered and obviously there's nothing in there to print. So if I were to just simply print other h1 Hello, well and go back go to here, print. Oh, I forgot to reload it. My bad. Oh, I wonder why did that not work?
There we go. Okay, so if you want to actually trigger it programmatically, so like a button on your website triggers the print method. You can do that pretty easily. So I'll create a div and this will have an on click event. Oh, Click equals, print and print the page. Now what we do in here, we're gonna create a function called print up.
And then in here to print, it's actually really simple. You just do window, print, not Pre Owned, print, reload, click Print the page, as it says trigger there, and it's printing the entire page. And honestly, that's it. That's all there is to triggering the print event in a web browser via your website. If you have any questions, feel free to pop me a message. As usual, there will be a GitHub link to all of the source code and I look forward to seeing you in the next video.