Solved

javascript print screen

Posted on 2004-09-21
7
24,133 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to dynamically set the form action using jQuery.

861 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