Solved

javascript print screen

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

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

726 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