Solved

How to block print in web application?

Posted on 2004-10-14
12
293 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

860 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