Solved

Web page printing

Posted on 2002-06-10
14
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
What You Need to Know when Searching for a Webhost Provider
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

632 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