DEV Community

Cover image for Print page with JS
Rodrigo Cordeiro
Rodrigo Cordeiro

Posted on

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

Top comments (0)