{ e.prev" /> { e.prev" /> { e.prev"/>

How to cancel primary print dialog from poping up

44 Views Asked by At

I try to chancel a print event with pure JavaScript. For this, i have created the following code:

window.addEventListener("beforeprint", e => {
    e.preventDefault();
    e.stopPropagation();
    console.log('default print canceled');
    // Code to open new page and print from there
});

I can see in Dev Console the output 'default print canceled' and the code after that is executed. However before that, also the standard print dialog opens. But the standard dialog should not come up, since i stopped that with preventDefault();. There is no error in Dev Console. Can someone please tell me, what im doing wrong?

0

There are 0 best solutions below