Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
onafterprint event only works once

I need to carry out my own procedure after calling up the print function of the browser. The problem is that it only runs it once.

What can I do to make the onafterprint event always run?

window.onafterprint = function() {
  location.href = '{% url 'logout_' %}';
}

Swal.fire({
  title: 'Example',
  showDenyButton: true,
  showCancelButton: true,
  confirmButtonText: 'Yes',
  confirmButtonColor: 'green',
  denyButtonText: 'No',
  cancelButtonText: 'Cancel'
}).then((result) => {
  if (result.isConfirmed) {
    flPrint = true;
  } else if (result.isDenied) {
    flPrint = false;
  }

  if ((result.isConfirmed) || (result.isDenied)) {
    $.ajax({
      url: '{% url 'ajax-view' %}',
      dataType: 'json',
      contentType: "application/json",
      type: 'GET',
      success: function(r) {
        if (r.result) {
          if (flPrint) {
            window.print();
          } else {
            location.href = '{% url 'logout_' %}';
          }
        }
      },
      error: function(err) {
        console.log(err);
      }
    });
  }
})
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!