Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Print | Q347 [ previous next ]

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>

©2018 Martin Webb