question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onPrintDialogClose not working with Chrome Version 86.0.4240.75 (Official Build) (64-bit)

See original GitHub issue

I use the PrintJS library for pdf print and I used to call the onPrintDialogClose function to reload after I close the dialogue window. But since the latest chrome version, the function is being skipped altogether and not triggering. Although the dialogue window is opening but the onPrintDialogClose functionality is not triggering and skipping.

sample code which was working before:

window.printJS({printable:url, type:'pdf', onPrintDialogClose: function(){ window.location.href = "/"; window.location.reload(); }});

EDIT: Interesting point: If I switch screen or toggle any opened tab or open a new tab and come back. The reload function triggers then.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:12
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
kruzzzecommented, Nov 25, 2020

I opened a pull request.

What workround can I suggest:

After calling printJS ()

add the following code:

  const handler = () => {
    // Make sure the event only happens once.
    window.removeEventListener ('mouseover', handler)

---------- your callback function here--------------

    // Remove iframe from the DOM, by default 'printJS'
    const iframe = document.getElementById (frameId)

    if (iframe) {
      iframe.remove ()
    }
  }

  setTimeout (() => {window.addEventListener ('mouseover', handler)}, 1000)

It may still need to be checked for specific browsers, I checked it only for Chrome.

Tell me, if it doesn’t work, I’ll try to find something else.

1reaction
ermarkarcommented, Nov 25, 2020

I opened a pull request.

What workround can I suggest:

After calling printJS ()

add the following code:

  const handler = () => {
    // Make sure the event only happens once.
    window.removeEventListener ('moseover', handler)

---------- your callback function here--------------

    // Remove iframe from the DOM, by default 'printJS'
    const iframe = document.getElementById (frameId)

    if (iframe) {
      iframe.remove ()
    }
  }

  setTimeout (() => {window.addEventListener ('mouseover', handler)}, 1000)

It may still need to be checked for specific browsers, I checked it only for Chrome.

Tell me, if it doesn’t work, I’ll try to find something else.

this is working but there is spelling mistake for mouseover event

Read more comments on GitHub >

github_iconTop Results From Across the Web

A brand new website interface for an even better experience!
onPrintDialogClose not working with Chrome Version 86.0.4240.75 (Official Build) (64-bit)
Read more >
[HELP] Stops work with new CHROME version 86.0.4240.75
Hello Guys. After I update my google chrome to version: 86.0.4240.75 I simply can't use jitsy anymore, I get this message: "Failed to...
Read more >
Check box not activating on Chrome [Version 101.0.4951.41 ...
Does a regular html <input type="checkbox"> work? It might be a browser bug if that's the only one it doesn't work on. –...
Read more >
Google Chrome (64bit) 86.0.4240.75 - Filepuma.com
Whenever Google releases a new update, it installs the corresponding files. Therefore, many users do not know which version of Chrome they have ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found