Solved

How to block print in web application?

Posted on 2004-10-14
12
263 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
squareUp  challenge 22 106
factorial example challenge 10 61
Path of Workbook 3 45
C# code editing and collaboration 3 44
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
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 …
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…

705 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

18 Experts available now in Live!

Get 1:1 Help Now