I am just detecting the printed status in web browser. As you can see , browser support the status as cancel or print button. For seeing if user clicked cancel, print button, I
window.print()
doesn't return any value.
I don't think there's a way to know if the user clicked Save or Cancel. It's more of your operating system's job to watch what's going on in there. There're, however, two event handlers
window.onbeforeprint
and window.onafterprint
.Code Snippet
window.onbeforeprint = function() {
console.log('This will be called before the user prints.');
};
window.onafterprint = function() {
console.log('This will be called after the user prints');
};
Take a look here