This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Disabling the print Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Disabling the print" Watch "Disabling the print" New topic

Disabling the print

Nilesh Srivastava
Ranch Hand

Joined: Aug 29, 2003
Posts: 70
Hi All,
My requirement is to restrict the user from printing the web page through PRINT button functionality of browser.
Can anyone tell me how to do that.
My aim is to restrict the user from printing the page.There are certain wayz thru which a user can print :
1)Thru PRINT button of broswer
2)Ctrl+C Ctrl+V (I have clue to disable it)
3)Printscreen button of Keyboard(Can be done thru JavaScript)
4)Right Clicking(Can be disabled)
Is there any other way to print the web-page.
Please guide me.
Thanks in advance
Sim Raina
Ranch Hand

Joined: Nov 20, 2003
Posts: 33
to copy ============> ctrl insert
to delete============> shift delete
to paste =======> Shift insert

if u can't impress people with ur intelligence , confuse them with ur bullshit
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
I'm moving this to the HTML & Javascript forum. Please continue this disucssion there. Thank you

[Blog] [Blogroll] [My Reviews] My Linked In
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
Basically the page can be captured many ways from saving it, to copy and pasting, to print screen, to getting it from the temp files, to just writing it out on a piece of paper with a pen and pencil.
Can you block the print button?
try playing with this line of code, it might get your boss off of your back

Brian Pipa
Ranch Hand

Joined: Sep 29, 2003
Posts: 299
it's useless to try and block printing. If someone really wants to do it, they will.

My Java Freeware:<br />MACCC - <a href="" target="_blank" rel="nofollow"></a><br />Nator - <a href="" target="_blank" rel="nofollow"></a>
Nilesh Srivastava
Ranch Hand

Joined: Aug 29, 2003
Posts: 70
Thanks Eric,
It helped me in getting rid of my Boss.It really helped me.
But I still have a doubt.If we can trap the print event like this and fool the user,then the print button can also be trapped for no print and even if user click the print button , no out put will come.
Could u/anyone plz help me in this issue.
Thanks a lot to all of u
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
You are basically stuck with that
It is sorta covered in the JavaRanch Style Guide.
subject: Disabling the print
Similar Threads
printing from an applet toolbar the image displayed in the applet via a thread
Avoiding page expiry
Need to restrict ctrl+c, ctrl+v, ctrl+x
Is any way We can tell JSF to not response
Printing from a jsp page- java attributes...?