显示确认弹出窗口,并禁止单击侧面弹出窗口,如Facebook,如何?

时间:2018-07-05 04:57:36

标签: javascript html

我希望用户不能单击弹出的确认弹出窗口。怎么做?当我单击“后退”按钮(浏览器)时发生弹出窗口

if (window.history && history.pushState) {
  addEventListener('load', function () {
    history.pushState(null, null, null);
    addEventListener('popstate', function () {
      var stayOnPage = confirm("Are you sure? Mission will be failed");
      if (!stayOnPage) {
        history.pushState(null, null, null);
      } else {
        window.location = 'google.com';
      }
    });
  });
}

0 个答案:

没有答案