I've been printing my page using the code below:
window.print();
An image below is what the print preview in Google chrome browser looks like. It has two main buttons: print
and cancel
.
I want to know if the user has clicked the print
or cancel
buttons. What I did uses jquery:
HTML Code of the Print Preview:
<button class="print default" i18n-content="printButton">Print</button>
<button class="cancel" i18n-content="cancel">Cancel</button>
Jquery Code:
$('button > .cancel').click(function (e) {
alert('Cancel');
});
$('button > .print').click(function (e) {
alert('Print');
});
I tried the code above with no luck. What am I missing?
button > .cancel
would have not selected the cancel button, but an element withcancel
class inside a button. The right selector would have beenbutton.cancel
(but that won't work anyway) – Paradox