Solved

Web page printing

Posted on 2002-06-10
14
162 Views
Last Modified: 2013-12-24
Is there any way to keep a user from being able to print a web page?  I know this is a long shot but just curious.
0
Comment
Question by:tdenny
  • 7
  • 4
  • 3
14 Comments
 
LVL 19

Accepted Solution

by:
cheekycj earned 100 total points
ID: 7068660
AFAIK, this is not possible at all.

What you can do is make it harder for the user to print by using a dark background and light text (like black background with white text).. so if the user doesn't have print backgrounds enabled (most don't) then it will print as a blank page (white text on white paper)

CJ
0
 

Author Comment

by:tdenny
ID: 7070113
CJ,

Thanks as usual for your response.  I didn't think there was any way possible but thought I'd ask for the heck of it.  Your work around is very clever though.  Take care
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7070149
Good luck and thanx for the "A".

CJ
0
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 

Expert Comment

by:conman2k
ID: 7070919
You can prevent printing, do this:
<!-- STEP ONE: Copy the event handler into the BODY tag  -->


  <BODY onBeforePrint="document.body.style.display = 'none';"
        onAfterPrint="document.body.style.display = '';" ondragstart="return false" onselectstart="return false">


<!-- Script Size:  0.81 KB -->

The user will get a blank page as print output.

You can prevent 'right clicking' and 'copying' by using this javascript on the page:
<script language="JavaScript1.2">
<!--


top.window.moveTo(0,0);

//-->
</script>

<html>

<head>

<SCRIPT LANGUAGE="JavaScript">

<!--
var sorry="Sorry, copying or printing from this page is not allowed. This document is for internal use only."

function click(e)
{
    if (document.all)
    {
        if (event.button == 2)
        {
           alert(sorry);
           return false;
        }
    }
    if (document.layers)
    {
        if (e.which == 3)
        {
            alert(sorry);
            return false;
        }
    }
}

if (document.layers)
{
    document.captureEvents(Event.MOUSEDOWN);
}

document.onmousedown=click;
//-->

</SCRIPT>

Use both together and you have a pretty secure page. Even if a user is smart enough to do a control 'p', they still get a blank page.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7070932
those styles on work IE 5+, I believe.

also... a smart user will do cntrl-a and then paste and then print ;-)

CJ
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7070933
or save the page locally and print :-)
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7070936
sorry for all the posts.. but the best way to prevent someone from printing is don't put it on the web.

CJ
0
 

Expert Comment

by:conman2k
ID: 7070960
Incorrect. Try the code. I do this internally on our intranet for items we do not want to leave the building. Control A and Control C are prevented by the combo above. (I just verified it.) Control P works, but of course only a blank page is printed.

I prevent the saving of the page locally by having the text in question pop up in a window with no menu bars.

The only thing possible is a print screen copy, which gives them a graphic. If they are that desperate, they will just hand re-write it anyway.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7070983
onselect.. disables the selection of text.. I guess...
but how do you prevent cntrl-s.

and this doesn't work on NS does it... NS doesn't support those styles, as far as I know.

on the internet you can't control the user's browser type.

CJ
0
 

Expert Comment

by:conman2k
ID: 7070999
Yea, in our controlled IE environment it works pretty well. On the Internet it would help, but not 100%.  I have not tried Netscape on the code since to save money we develop internally for just one browser. If someone tries it on Netscape, please let me know.

I just tried a control s and it does not work either. (this code rocks.)  I would imagine that there is similar code out there for Netscape.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7072956
Well since NS doesn't support some of those styles.. I doubt it will work in NS.

CJ
0
 

Author Comment

by:tdenny
ID: 7073220
Conman, CJ,

Thanks again.  I will try it.  Unfortunately we are not limited to one browser.  In fact we used to be a NS only shop (this really stinks) - but we now are very slowly moving towards IE as the more commonly used browser.  I wish we could only code for one in our intranet.
0
 

Author Comment

by:tdenny
ID: 7073296
Conman,

I tried your code and it works nicely.  I didn't try Netscape yet.  I am still able to use the Control C to cut and paste though.

I agree that not putting it on the web would be the best solution but we are giving our users a little test (nothing serious) and we were just trying to make sure that they didn't print all the correct answers and hand them off to the guy sitting next to them.  I'm assuming that they are smart enough to figure that out.  Again it's nothing serious.
0
 

Author Comment

by:tdenny
ID: 7073355
Conman,

I tried your code and it works nicely.  I didn't try Netscape yet.  I am still able to use the Control C to cut and paste though.

I agree that not putting it on the web would be the best solution but we are giving our users a little test (nothing serious) and we were just trying to make sure that they didn't print all the correct answers and hand them off to the guy sitting next to them.  I'm assuming that they are smart enough to figure that out.  Again it's nothing serious.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
php.ini on ipage hosting 12 67
Grub Broken on Ubuntu 16.04 LTS, Mate 1.14 GUI 5 245
Coldfusion Datefield problem 2 122
Configure a Local PHP Interpreter for Phpstorm 2 350
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 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