1

我想要做的是检测浏览器关闭事件(在浏览器卸载时)并打开一个新的弹出窗口,其中我们有一些选项,例如(提供反馈,再次转到页面,给我发送报告等)。同时我希望父窗口活着,直到用户在弹出窗口中选择一个选项。我尝试了以下,它似乎不起作用。

$(window).bind('beforeunload', function(event){
        event.preventDefault();
    });

请给我正确的方向来实现这一目标。

4

2 回答 2

2

你只能通过警报/对话框来做到这一点

$(window).bind('beforeunload', function(event){
    return "hold on a minute there, conme back and answer some questions";
});
于 2013-08-08T04:37:35.567 回答
0

您可以这样做,但用户不会在 Chrome 中看到它,除非他们禁用弹出窗口阻止程序。

$(window).on("beforeunload", function(){
    window.open("survey.html");
    return "Are you sure you want to leave?";
});
于 2013-08-08T04:41:00.267 回答