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

357
Views
Custom text for beforeunload alert box in angular

I have been working on a solution where I need to show custom text in beforeunload event. I have seen many questions here, but none of them seems to be working. So for angular is there any way using which we can update the text of the alert box? As I want to show the text in both English and French, depending upon language selection.

The code :

listenerFucntion = (event) => {
  // Cancel the event as stated by the standard.
  event.preventDefault();
  // Chrome requires returnValue to be set.
  event.returnValue = 'You are currently in edit mode. Are you sure you want to refresh the page?';
  
}

addAlertWithListener(){

 window.addEventListener('beforeunload', this.listenerFucntion ,true);
}
removeAlertWithListener() {
  window.removeEventListener('beforeunload', this.listenerFucntion,true);
}

Here as you can see I am trying to change the text but all I am getting is : enter image description here

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

0

Changing the message is no longer supported by the standard, so most (if not all) modern browsers will ignore this.

See the specifications here, particularly the note under point 8:

The message shown to the user is not customizable, but instead determined by the user agent. In particular, the actual value of the returnValue attribute is ignored.

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!