Solved

javascript print screen

Posted on 2004-09-21
7
24,123 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
Comment Utility
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
Comment Utility
i meant the printscreen button on ur keyboard.
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

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…
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
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:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

762 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

6 Experts available now in Live!

Get 1:1 Help Now