Reputation: 607
What I want to do is detecting the browser close event (on browser unload) and open up a new pop up where we have some options like (give a feedback, go to the page again , mail me a report etc). At the same time I want the parent window alive till the user select an option in pop up window. I tried following and it seems not working.
$(window).bind('beforeunload', function(event){
event.preventDefault();
});
Please give me the right direction for achieving this.
Upvotes: 1
Views: 2683
Reputation: 86240
You can do this, but users won't see it in Chrome unless they disable the pop-up blocker.
$(window).on("beforeunload", function(){
window.open("survey.html");
return "Are you sure you want to leave?";
});
Upvotes: 0
Reputation: 1411
you can only do it with an alert/dialog
$(window).bind('beforeunload', function(event){
return "hold on a minute there, conme back and answer some questions";
});
Upvotes: 2