记录一下: onbeforeunload()方法, 避免未保存而关闭页面.
记录一下: onbeforeunload()方法, 避免未保存而关闭页面.
ToToggleSubmitForm()用于提交按钮的Onclick();theform为当前表单.
1 var m_btnSubmit = true;
2
3 window.onbeforeunload = function(e) {
4 if (!e && window.event)
5 e = window.event;
6 if(m_btnSubmit)
7 e.returnValue ="您还没有保存, 确定放弃吗?";
8 }
9
10 function ToToggleSubmitForm() {
11 m_btnSubmit = false;
12
13 var theform;
14 if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
15 theform = document.forms["Form1"];
16 }
17 else {
18 theform = document.Form1;
19 }
20 theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
21 theform.__EVENTARGUMENT.value = eventArgument;
22 theform.submit();
23
24 m_btnSubmit = true;
25 }
2
3 window.onbeforeunload = function(e) {
4 if (!e && window.event)
5 e = window.event;
6 if(m_btnSubmit)
7 e.returnValue ="您还没有保存, 确定放弃吗?";
8 }
9
10 function ToToggleSubmitForm() {
11 m_btnSubmit = false;
12
13 var theform;
14 if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
15 theform = document.forms["Form1"];
16 }
17 else {
18 theform = document.Form1;
19 }
20 theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
21 theform.__EVENTARGUMENT.value = eventArgument;
22 theform.submit();
23
24 m_btnSubmit = true;
25 }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步