How to stop user from printing webpages? using javascript or jquery

As has already been noted, you cannot do this. However, one commonly used trick is to try and hide all the page content if it’s being printed:

<style type="text/css" media="print">
    body { visibility: hidden; display: none }
</style>

But this is not guaranteed to work, and it’s easy to get around if you have even a vague idea what you’re doing.

Leave a Comment