Solved

javascript print screen

Posted on 2004-09-21
7
24,125 Views
Last Modified: 2012-06-21
can we detect using javascript, the pressing of the print screen button, on html web form.
can anyone enlightne me.

Karthik
0
Comment
Question by:rkarthik29
7 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 12115290
googling on 'javascript onprint' lead me to believe you could create two functions in javascript:

function window.onbeforeprint(){
}
function window.onafterprint(){
}

but i cannot test things myself - except for the 'print preview' which seems to work okee-, because I haven't got a printer installed on this pc.

regards

-r-
0
 
LVL 4

Author Comment

by:rkarthik29
ID: 12116421
i meant the printscreen button on ur keyboard.
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 250 total points
ID: 12117741
No.  

Print screen is implement with OS objects that are outside of browser space. It initiates from hardware interrupts.  You cannot do anything to detect it or program off of it from the browser.  I think even with activex you would not be able to do it.

Cd&
0
 
LVL 8

Expert Comment

by:radnor
ID: 12118878
This will put 2 buttons on yuor screen.  The 1st is a PRINT and the 2nd is CLOSE THIS WINDOW (I have it in a popup window).

document.write('<form>'

+ '<input type=button name=print value="Print this page" '

+ 'onClick="javascript:window.print()"> '

+ '<input type=button name=close value="Close this page" '

+ 'onClick="javascript:window.close()"></form>');

If you do not want the "close this page", just have this:

document.write('<form>'

+ '<input type=button name=print value="Print this page" '

+ 'onClick="javascript:window.print()"> '

+ '</form>');

This will print the web page it is on.

If you need any additional info, let us know.

Radnor
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12123041
Radnor,

Please read the question and comments.  The member has alredy indicated that is not what they want.  They are referring to "printsceern", not the print function of the browser.

Cd&
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Read XML Response From ASP Classic 9 66
Snap images to the bottom of a div 5 65
Problem to picture file 3 66
Questions about this React unit test 4 42
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to dynamically set the form action using jQuery.

929 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now