记录一下: 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 }