记录一下: onbeforeunload()方法, 避免未保存而关闭页面.

ToToggleSubmitForm()用于提交按钮的Onclick();theform为当前表单.

 1 var m_btnSubmit = true;
 2 
 3 window.onbeforeunload = function(e) {
 4     if (!&& 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 }

相关文章:

  • 2021-05-29
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
相关资源
相似解决方案