Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q347 How can I allow the user to confirm before printing a page?

irt.org | Knowledge Base | JavaScript | Print | Q347 [ previous next ]

Q347 How can I allow the user to confirm before printing a page?

The following works for me, although Netscape allows the user to cancel the print request for the built-in dialogue box, so adding a confirm box seems a tad excessive:

<SCRIPT LANGUAGE="JavaScript"><!--
function myPrint() {
    if (window.print) {
        if (confirm("Print Page?")) {
            window.print();
        }
    }
}
//--></SCRIPT>

<SCRIPT LANGUAGE="JavaScript"><!--
if (window.print)
    document.write('<FORM><INPUT TYPE="BUTTON" VALUE="Print" onClick="myPrint()"><\/FORM>');
//--></SCRIPT>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.