Solved

How to block print in web application?

Posted on 2004-10-14
12
276 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
 

Author Comment

by:LorneBackler
ID: 12429324
Ok thanks it works. It prints a blank page.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now