I was looking for JQuery solution which will fire only when I close a modal popup window. I found some JQuery examples but none of them gave me correct JQuery solution. What I was looking is that whenever I close the modal popup Window, it prompts with message before closing and redirect to particular page. So I got the following JQuery solution, But the issue in this solution is that it will fire on both event "close" and "reload or post back". This is wrong. I want a JQuery solution which should work only on closing a modal popup window, not on reload or post back.
$(window).unload(function() {
//redirection code here
alert('your message');
});
So after some research, I made it and solved the issue with following. I hope this will help you as well.
$(window).unload(function(event) {
if (event.target.readyState=='complete') {
alert('Closing Window and redirecting...');
var opener = window.dialogArguments;
opener.parent.location = '../YourRedirected.aspx?id=<%=Record_ID %>';
top.window.close();
}
else {
alert('Reloading Window');
}
});
No comments:
Post a Comment