我有一个基本的功能,提醒用户刷新,浏览器后退按钮(除了提交按钮)或当一个链接被点击时,他们将丢失表单向导中的表单数据。
<script type="text/javascript">
var okToSubmit = false;
window.onbeforeunload = function() {
document.getElementById('Register').onclick = function() { okToSubmit = true; };
if(!okToSubmit) return "Using the browsers back button will cause you to lose all form data. Please use the Next and Back buttons on the form";
};
</script>我正在使用jAlert插件的警报,并希望使用jConfirm的上述功能。当我在“works...for”之后添加返回时,它会返回一秒钟。它弹出警告,然后页面刷新,对话框消失。有人知道怎么解决这个问题吗?
发布于 2010-06-16 01:54:26
我相信你仍然需要卸载,否则仍然会发生return false;操作。我对这个插件不太熟悉,但可以试试这样的东西:
// your code
if(!okToSubmit)
{
alert( "Using the browsers back button will cause you to lose all form data. Please use the Next and Back buttons on the form" );
return false;
}
// the rest of your codehttps://stackoverflow.com/questions/3047430
复制相似问题