如何使用window.onbeforeunload将用户导航到特定页面

时间:2015-09-29 13:07:49

标签: javascript jquery

我想使用onbeforeunload将用户导航到特定页面。有没有办法实现它?

window.onbeforeunload = function() {
          //return 'The changes you made will be lost if you navigate away from this page.';
          if (flag) {
              navigateTo('index');
              else {
                  navigateTo('list');
              }
          }
          return 'The changes you made will be lost if you navigate away from this page.';
      };

0 个答案:

没有答案