Detect Print Popup Opening or a Dowload

Asked

Viewed 56 times

0

i was wondering if anyone knows any way to detect the opening of that standard print popup for the execution of a javascript.

My problem: I needed to run a script when the user downloaded or printed a PDF that is being displayed to him as follows within my page:

Esse é aquele visualizador padrão do navegador

He would have to use these two default viewer embebbed options. Does anyone know how I would capture these events with javascript? (Remembering that the viewer code is external, I could not capture the button ids).

1 answer

0


Christian I confess that I don’t quite understand what you want to do, but I left an example for you to see how you can perform an action before printing using the native javascript method onbeforeprint:

function Antes() {
  window.onbeforeprint = function() {
     alert('Antes de imprimir!')
  }
}

function Imprimir() { 
  window.print()
}
<button onclick="Antes();Imprimir()">Imprimir</button>

  • Until not, almost this more I can’t put an "onclick" on the default browser viewer print button...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.