Safari - printing page

Hi all!
Faced with this problem (maybe someone has already found a solution)
(stack: React + Gatsby)

I added the ability to print the page on the website:

document.execCommand('print', false, null;);

In Safari, the first click on the print button (function call) - everything works correctly
When user click the button again (second and subsequent until the page reloads forcibly) - the browser shows a popup,

after confirming it the print window opens with empty endless sheets (it’s not even possible to print them - browser freezes, you have to force quit)

Has anyone solved a similar problem? (This seems to be a recent bug - it worked fine before)

Hello @Elena_Bychkova

execCommand is deprecated so you should avoid using it

did you tried to use other browser ?does it has same issue or it just safari?

there also extra ; after null in your code
it should be
document.execCommand('print', false, null);

i found this one also

sorry i do not have windows or mac to use safari to test it

i guess you can use



Go to Safari->Settings->Security and deactivate JavaScript button.
Then go to ->Tabs and activate “Open new tabs or window in foreground”.
Then go back to Security and re-activate JavaScript option :wink: