当用户试图离开时,我会在某些条件下显示提醒消息。该消息显示在Safari中,但它在Chrome中不起作用 我尝试过以下两件事:
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!'
}
}
答案 0 :(得分:0)
我认为这适用于chrome。我也怀疑isFormChanged。
<script type="text/javascript">
window.onbeforeunload = function() {
return "Are you sure you want to close window?"
}
</script>