0

I am trying to refresh the page on click function.

reloadPage(){
 this._$window.location.reload();
 this._$window.onbeforeunload = null;
}

Above code is working fine in Chrome and IE. But in Firefox getting prompt message saying this page is asking you to confirm that you want to leave - data you have entered may not be saved.

How to prevent this in Firefox?

Note: Without Jquery.

Nagarjuna Reddy
  • 4,083
  • 14
  • 41
  • 85
  • have you tried this? [How to control browser confirmation dialog on leaving page?](https://stackoverflow.com/questions/19179514/how-to-control-browser-confirmation-dialog-on-leaving-page_ – moghya Mar 14 '18 at 06:23
  • @moghya, there also it is working in Chrome & IE. They didn't mention about Firefox. – Nagarjuna Reddy Mar 14 '18 at 06:47

2 Answers2

1

You can use the set time out function and i expect it'll work in any situation and in any browser. Please have a look at below code snippet.

setTimeout(function(){
  window.location.reload();
});

or simply:

setTimeout(location.reload)
Yash
  • 171
  • 2
  • 8
1

This should allow you to reload without a prompt:

window.location.href = window.location;

See pen: https://codepen.io/ndcunningham/pen/mjpdEE?editors=1111

Nico
  • 1,961
  • 17
  • 20