I'm showing an alert message on certain conditions when an user tries to leave. The message is shown in Safari, but it doesn't work in Chrome.
I tried two things like following:
window.onbeforeunload = function(event) {
if ($scope.isFormChanged == true) {
event.returnValue = 'Don\'t go yet! Save your changed data before you leave!';
}
}
window.onbeforeunload = function() {
if ($scope.isFormChanged == true) {
return 'Don\'t go yet! Save your changed data before you leave!'
}
}
I think this works in chrome. And I have also doubt with isFormChanged.
<script type="text/javascript"> window.onbeforeunload = function() { return "Are you sure you want to close window?" } </script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.