Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
166
rated 0 times [  172] [ 6]  / answers: 1 / hits: 18508  / 12 Years ago, thu, march 29, 2012, 12:00:00

I have defined onbeforeprint and I modify my html code and now once I finish printing that is on select of print button I want the onafterprint to be fired but it does not.


Instead when I press the Control + Print button the onbeforeprint is fired first and then the onafterprint event and then print dialog is shown.


Is there any way I could in some way do changes to my html after the Print button is clicked?


Am using IE -9 browser and the code is as follows:


Code


<script type="text/javascript">
window.onbeforeprint = function () {
alert('Hello');
}
window.onafterprint = function () {
alert('Bye');
}
</script>

More From » html

 Answers
72

onbeforeprint fired before dialog appears and allows one to change html and so on.



onafterprint is fired just before dialog appears. It is not even possible to know, whether document was actually printed or user canceled it. Needless to say about when printing finished (if started at all).



Again: no event is available to track anything happened in print dialog, i.e. answer to your question is no.



Moreover, I hope what your need will never be implemented, cause this allows to frustrate user. He/she asks to print one document, but got something different.


[#86543] Wednesday, March 28, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maxh

Total Points: 137
Total Questions: 100
Total Answers: 103

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
;