-1

I am using angular controller,In that user refresh the page manually,In that time I want show the alert popup or restrict that refreshing the page.

kboul
  • 13,836
  • 5
  • 42
  • 53
  • Hello and welcome to StackOverflow. Please take some time to read the help page, especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). And more importantly, please read [the Stack Overflow question checklist](http://meta.stackexchange.com/q/156810/204922). You might also want to learn about [Minimal, Complete, and Verifiable Examples](http://stackoverflow.com/help/mcve). – 31piy Dec 19 '17 at 05:37
  • https://stackoverflow.com/questions/3221161/how-to-pop-up-an-alert-box-when-the-browsers-refresh-button-is-clicked – Paresh Gami Dec 19 '17 at 05:38
  • I want custom popup,not predefined popup – Bindhu Yanamadala Dec 19 '17 at 05:46

1 Answers1

0

You can listen for beforeunload event. beforeunload event will be triggered when someone hits a F5 or refreshes the page

var windowElement = angular.element($window);
windowElement.on('beforeunload', function (event) {
     alert('user is trying to navigate');
})
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396