0

I am using angular 6 for my project, I need to restrict the user from refreshing the page.

  • when the user tries to click on the refresh button of the browser or press ctrl+f5 etc, I would like to restrict the user and show the page for it.

show alert message if he is refreshing the page

Niladri
  • 5,832
  • 2
  • 23
  • 41
Hitesh
  • 4,098
  • 11
  • 44
  • 82
  • Can you please show what you tried to accomplish so? – briosheje Sep 12 '18 at 12:17
  • Possible duplicate of [Browser Restriction | angular 6 | restrict back navigation](https://stackoverflow.com/questions/52294840/browser-restriction-angular-6-restrict-back-navigation) – David Sep 12 '18 at 12:25
  • @briosheje - When user clicks on refresh button i want to show an alert message – Hitesh Sep 12 '18 at 12:47
  • you need to listed to `window.onbeforeunload` event and show the alert message – Niladri Sep 12 '18 at 15:47
  • @Niladri - in angular 6? – Hitesh Sep 12 '18 at 20:57
  • @Hitesh yes you can do it in Angular 6 also .. check my answer here https://stackoverflow.com/questions/47834775/window-onbeforeunload-importing-in-angular2/47834828#47834828 – Niladri Sep 13 '18 at 08:25

0 Answers0