Solved

How to block print in web application?

Posted on 2004-10-14
12
286 Views
Last Modified: 2008-01-16
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
Comment
Question by:LorneBackler
  • 3
  • 3
  • 2
  • +1
12 Comments
 
LVL 10

Expert Comment

by:dis1931
ID: 12315195
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
 
LVL 6

Accepted Solution

by:
sandeshj earned 125 total points
ID: 12317395
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
 
LVL 8

Expert Comment

by:tomvergote
ID: 12317560
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:LorneBackler
ID: 12429324
Ok thanks it works. It prints a blank page.
0
 
LVL 10

Expert Comment

by:dis1931
ID: 12429357
I like the reference to user $#!@#.

Dis
0
 
LVL 8

Expert Comment

by:tomvergote
ID: 12435765
> 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
 
LVL 6

Expert Comment

by:sandeshj
ID: 12465383
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
 
LVL 8

Expert Comment

by:tomvergote
ID: 12592703
"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
 
LVL 6

Expert Comment

by:sandeshj
ID: 12826328
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question