• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to trap the Print Screen

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a web page I need to trap the print screen key, so that the
user cannot print my page.
what should I do for that.I tried using Javascript using clipboard property,but some times it works in Internet Explorer,
In Netscape no respond.Please give some idea.
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not tried this before, but I would be surprised if you could do this. The printscreen function is part of the windows environment, so you are trying to write an app that gets sent over the web to disable a clients operating system functionality. Don't know if you can do that.
Just as a side note, why would you do that? It always irritates me when I go to a site and they do something on the page that takes away some functionality that I have grown to like and expect out of my browser. Like someone was talking about disabling the right click. I always right click, and I was to go to a sight that took that away, the first thing I am going to do is disable my Javascript to see why they are doing that, because it just irritates me and makes me suspicious. I am all for designing a page using layers, dhtml, pop-ups, and letting the programmer have control of what they are doing, but disabling my browsers and windows capabilities like back buttons, history, right click, and print screen seems not worth it.
Just my thoughts.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with you Bill. Web developers must start to realize that they are visitors in my home and I expect them to treat my things with respect. I don't want them messing with my browser. Besides it just exposes that they are stupid since we can just turn off JS and revisit the site. (So what was the big secret in their code that they didn't want me to see it?)
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You guys are assuming that the given website is an internet site. If you are attempting to build a browser-based intranet application, there are times when you will want to disable the printscreen key so that information can be protected.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Print Screen Kewy is the only key that can not be detected if it was pushed, sorry to say. You can detect any other key!
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup man print screen is not being detected.
I kind of am busy so cant explore this topic much but I like to add something.
Each key on the keyboard has a code like j has 106.
If u can find the code for the print screen key maybe things would work.
Here is link to place where they have a sample code to detect key strokes. See if it helps u.
http://www.htmlgoodies.com/beyond/keycapture.html
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The print screen key does not have a code, that is what i was trying to explain above. I have looked into this months ago for a project I was working on.
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
does the window key have an ASCII code? i need to capture that key. is it possible in javascript?
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Clear the clipboard if you can, so the user when he tries to paste will lose the information.
2)Have a css for print media to disable any printing.
3)Diable print options from context menu.

But after doing all the above it will only take less than a minute to be able to print your webpage...there is still more that one way to capture a screen from browser.

So i would suggest reconsidering your options like:
Adding a watermark or putting a disclaimer if this is an intranet application or add security to restrict to specific users.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by San Sreeds:
1) Clear the clipboard if you can, so the user when he tries to paste will lose the information.
2)Have a css for print media to disable any printing.
3)Diable print options from context menu.

But after doing all the above it will only take less than a minute to be able to print your webpage...there is still more that one way to capture a screen from browser.

So i would suggest reconsidering your options like:
Adding a watermark or putting a disclaimer if this is an intranet application or add security to restrict to specific users.



ALl useless.....You can not stop this from happening. Most browsers disable JavaScripts ability to use the clipboard. Etc. If you do not want content to be printed and saved, do not put it online.

Eric
reply
    Bookmark Topic Watch Topic
  • New Topic