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

163
Views
Javascript refresh page alert returns wrong result

I would like to make an alert, that when someine will refresh the page it will ask him or inform him something.

There are some examples, but in any case it works properly for me.

For instance, for code I've used here:

   window.onbeforeunload = function() {
   return "Data will be lost if you leave the page, are you sure?";
   };  
   $(document).on("submit", "form", function(event){
   window.onbeforeunload = null;
   });

I have constant message, like below:

enter image description here

The same applies to the second code:

 window.addEventListener('beforeunload', (event) => {
   event.returnValue = `Are you sure you want to leave?`;
 });

Is it something I am doing wrong here? I don't understand why the alert message is still thhe same.

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

0

Browsers now do not allow the app to specify that string any more. It was used maliciously to jam spam in.

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!