loading...
Cover image for Print page with JS

Print page with JS

rodcordeiro profile image rodcordeiro ・1 min read

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();
    }

Discussion

markdown guide