Service Portal - Change the text of the Leave Page alert "Leave Site: Changes you made may not be saved." Specifically when we have Cart Items before closing of window
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2020 07:13 AM
Hello Everyone,
Thanks in advance,
Recently we got a requirement to Change the text of the close browser page alert to change Text. when we have cart items in it.
I tried Customizing and Overriding "spSCNavStateManager" and changing the alert message in this directive and also tried using the below code.
$window.onbeforeunload = function (event) {
var answer = confirm('If you leave this page you are going to lose all unsaved changes, are you sure you want to leave?')
if (!answer) {
event.preventDefault();
}
return answer;
};
and
$scope.$on('$locationChangeStart', function( event ) {
//if (!$scope.form.$dirty) return;
var answer = confirm('If you leave this page you are going to lose all unsaved changes, are you sure you want to leave?')
if (!answer) {
event.preventDefault();
}
});
Anyone have a suggestion on how to make this possible?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2020 09:47 AM
Use below solution
Regards,
Sachin