weixin_33725270 2012-04-24 14:41 采纳率: 0%
浏览 59

AJAX和onbeforeunload事件

I have an aspx page. On the page I have a javascript function

window.onbeforeunload = confirmExit;
function confirmExit()
{
return "You have attempted to leave this page.  If you have made any changes to the fields      without clicking the Submit button, your changes will be lost.  Are you sure you want to exit   this page?";

}   

This executes when the user leaves the page. However it also executes on the partial page postbacks. How do I check to see if this is a partial page postback and ignore it?

  • 写回答

1条回答 默认 最新

  • 关注

    Can I prevent window.onbeforeunload from being called when doing an AJAX call

    See if the action you are doing does any of the following:

    onbeforeunload event

    To invoke this event, do one of the following:

    • Close the current window.
    • Navigate to another location by entering a new address or selecting a Favorite.
    • Click an anchor that refers to another document.
    • Invoke the anchor.click method.
    • Invoke the document.write method.
    • Invoke the document.close method.
    • Invoke the window.close method.
    • Invoke the window.navigate or NavigateAndFind method.
    • Invoke the location.replace method.
    • Invoke the location.reload method.
    • Specify a new value for the location.href property.
    • Submit a form to the address specified in the ACTION attribute via the INPUT type=submit control, or invoke the form.submit method.
    • Invoke the window.open method, providing the possible value _self for the window name.
    • Invoke the document.open method.
    • Click the Back, Forward, Refresh, or Home button.
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容