您是否尝试过此代码?
window.onbeforeunload = function (event) { var message = 'important: Please click on 'Save' button to leave this page.'; if (typeof event == 'undefined') { event = window.event; } if (event) { event.returnValue = message; } return message;};$(function () { $("a").not('#lnkLogOut').click(function () { window.onbeforeunload = null; }); $(".btn").click(function () { window.onbeforeunload = null;});});第二个功能是可选的,以避免在单击
#lnkLogOut和
.btn元素时提示。



