[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 322
  • Last Modified:

How to block print in web application?

Hi experts how can i block the ctrl print function from my web page.
I don't want my users to print the content of my web page.
I got some code snippets and scripts from internet but they don't work.
Is there a way or better way to achieve that task.
Thanks
0
LorneBackler
Asked:
LorneBackler
  • 3
  • 3
  • 2
  • +1
1 Solution
 
dis1931Commented:
Nearly impossible, they can always screen shot it, or mirror your site using a tool such as wget or other .  There is almost always a way to get around.  Even copy and paste works.
0
 
sandeshjCommented:
Hi!

If you just want to prevent the person from printing the page using Ctrl-p or using the print option in the browser you can do this...

<html>
<head>
<style type="text/css">
@media print
{
    .dontPrintMe
    {
          display : none;
    }
}
</style>
</head>
<body>
<div class="dontPrintMe">

......
.............the entire page  code is here........
............................
....................................

</div>
</body
</html>

This is guaranteed to work if the person browsing is a $#!@#, else as dis1931 says, its not possible to block it.

Cheers,
Sandesh
0
 
tomvergoteCommented:
there is always a way to print a page.
You can try to disable a lot of stuff, catch a ctrl p keypress, catch a right click catch whatver, that just affects the browser
If the user is browsing without javascript or is smart enough to use another tool to fetch the page (wget for example) he could change the source code and remove the script

I would leave it alone.
In this scenario I think explaining to the customer it's not reasonably feasible is the right thing to do.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LorneBacklerAuthor Commented:
Ok thanks it works. It prints a blank page.
0
 
dis1931Commented:
I like the reference to user $#!@#.

Dis
0
 
tomvergoteCommented:
> Ok thanks it works. It prints a blank page.

but as the poster pointed out: only if the visitor is not smart enough to work around it (disble css, save page and modify, ...)
0
 
sandeshjCommented:
Hi!
The aim is to stop a basic user from printing the page and that is solved. Only a minute ie less than 5% of the people being experts and again in that only a few may actually take the difficulty to extract the code to their local PC's. So I see no difficulty in implementing the method i mentioned, upon that... there is no other method you can implement this functionality that you want.

Cheers,
Sandesh,
0
 
tomvergoteCommented:
"Only a minute ie less than 5% of the people being experts and again in that only a few may actually take the difficulty to extract the code to their local PC's."

Most of the users don't care for the information either.
If there is a real reason to hide it, the lusers that want the page printed will just ask their wizzkid nephew and you're screwed. and most users are smart enough to try to copy paste the text at lease.
First of all I really don't see why you would put something on a website, but prevent it from being printed.
If it's sensitive info, why is it publicly posted? and if it isn't sensitive, who cares if it gets printed.
Secondly I really think that the users that benefit from printing the page (and maybe do you harm by printing it) will find out how easy it is
0
 
sandeshjCommented:
Hi!

I think when the author himself has made the comment that the code provided here works, then the points should be given appropriately.

Cheers,
Sandesh.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now