Print page with JS

rodcordeiro

Rodrigo Cordeiro

Posted on June 30, 2020

Print page with JS

Hey Devs, I'm here today to show you something amazing. How to print the page with JS.

Let's suppose you're have a form to fulfill a document and you need to print it. For this we're going to use a simple js function.

For this example, I'm going to use a button calling the function.

<button onclick="imprimir">Imprimir</button>                

Then, add the following script

    function imprimir(){
        window.print();
    }
💖 💪 🙅 🚩
rodcordeiro
Rodrigo Cordeiro

Posted on June 30, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related