除非我点击提交或保存按钮,否则我希望显示onbeforeunload
弹出式窗口。有任何想法吗?
到目前为止,我有这个:
Drupal.behaviors.PreventNavigation = function() {
window.onbeforeunload = function () {
return "Please save your work before navigating from this page";
}
}
答案 0 :(得分:0)
这是我的解决方案:
Drupal.behaviors.PreventNavigation = function() {
var clicked = false;
$('#edit-save').click(function() {
clicked = true;
});
$('#edit-submit-application').click(function() {
clicked = true;
});
window.onbeforeunload = confirmExit;
function confirmExit() {
if (!clicked) {
return "Please Save your work";
}
}
}