DEV Community

Cover image for Print page with JS
Rodrigo Cordeiro
Rodrigo Cordeiro

Posted on

3 3

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)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay