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

148
Views
Customize exit operation when closing tab or browser

Hi i'm trying to customize the operation made when a tab/browser is closed on my software. I've found a script that stop the execution of the closing operation and display a popup that ask to confirm the exit intent:

<script type="text/javascript">
    window.addEventListener('beforeunload', function(e) {
        e.preventDefault();
        e.returnValue='';
    });
</script>

I want to make this script execute other operation like showing a confirm dialog, but cant figure out how to make it. I want something like

<script type="text/javascript">
    window.addEventListener('beforeunload', function(e) {
        e.stopClosing();
        //Show confirm dialog
    });
</script>

I'm using Primefaces and JSF. Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

That's not possible in JavaScript because that would be a big security problem. Every browser has its own beforeunload dialog style and you can't customize it.

W3Schools says:

The default message that appears in the confirmation box, is different in different browsers. However, the standard message is something like "Are you sure you want to leave this page?". This message cannot be removed.

about 4 years ago · Juan Pablo Isaza Report
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!