如何在用户离开页面时创建弹出窗口?当前代码不适用于后退按钮

时间:2015-06-08 15:40:41

标签: javascript angularjs

当离开页面时,此功能在单击刷新或关闭页面时有效。当用户单击后退按钮时,它不起作用。有谁知道为什么这不能用后退按钮?

DB::table('table')
    ->where('column', 'operator', 'value')
    ->orWhere(function($query)
    {
        $query->where('column', 'operator', 'value')
            ->where('column', 'operator', 'value');
    })
    ->get();

这是HTML:

<script>
  function PopIt() {
    $("a.trigger").trigger('click');
    window.onbeforeunload = UnPopIt;
    return "Your changes have not been saved.";
 }
 function UnPopIt() { /* nothing to return */ }

  window.onbeforeunload = PopIt;

  $(document).ready(function () {
    $("a[id!=trigger]").click(function () { window.onbeforeunload = PopIt;});
  });

</script>

0 个答案:

没有答案