Forum Moderators: open

Message Too Old, No Replies

Is there an onPrint event, or some related function?

Running a script when user tries to print page.

         

Jeremy_H

6:36 pm on Aug 8, 2006 (gmt 0)

10+ Year Member



Hello,

Is there a way I can run a script if the user tries to print the page? Something like onPrint?

Thanks

penders

3:10 pm on Aug 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi Jeremy, I had not realised anything like onPrint existed, except I have just come across the two events:

window.onbeforeprint - Fires just prior to the page being printed
window.onafterprint - Fires immediately after the page to be printed out has been loaded into printer queue/cache.

It can also be actioned inside the BODY (can it be linked to other elements?):

<body onbeforeprint="dothis()">

I have not tried this myself, but I gather it is IE5+ only.

Tlife

10:44 pm on Aug 14, 2006 (gmt 0)

10+ Year Member



Interesting.

I tested it in IE6 and FF 1.5, results are as assumed.

It worked in IE6, didn't work in FF.