php - 如何询问一个人是否要关闭窗口?

标签 php javascript html popup

Possible Duplicate:
Javascript To Get An Alert When Closing The Browser Window

我有一个合理的理由问这个问题,我有一个网络应用程序来管理一个大型数据库,并且用于修改查找表的页面会在单独的窗口中弹出。我希望能够提醒用户,如果他们对表单所做的更改尚未保存到数据库中,并为他们提供这样做的选项,即使他们单击“X”关闭窗口也是如此。这可能吗?

最佳答案

这就是我所做的

window.onbeforeunload = function (e) {
  var e = e || window.event;
  if (allowNavigationsAwayFromPage != true)
      {
      // For IE and Firefox
      if (e) {
        e.returnValue = 'Are You Sure? Some operation is still going on';
      }

      // For Safari
      return 'Are You Sure? Some operation is still going on';

      }
};

allowNavigationsAwayFromPage 现在是一个变量。但我通常有一个函数来检查这一点。

关于php - 如何询问一个人是否要关闭窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13006547/

相关文章:

javascript - 在 IE 中禁用滚动条

css - 缺少索引文件 Brackets IDE

javascript - 如何动态更改DIV html代码中的某些数据

javascript - 从 Lodash 中的 JSON 中的多个嵌套集合中提取项目

javascript字符串将<替换为<

php - iOS推送通知: Not getting any push when sending this payload

php - 将文件上传到 mySQL 数据库。帮助代码

javascript - 使用位置 :sticky for the bottom of a div Container

php - 垃圾收集 Php

php - 多次插入后更新特定记录 - 可能使用last_insert_id()