Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Web page printing

Posted on 2002-06-10
14
Medium Priority
?
177 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 400 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

688 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