need to refresh web page after clicking close on pop-up window
I have a pop-up window a user logs 开发者_如何转开发into, once they are logged in successful, I have a message that has a link to close the window. But I want it to not only close that pop up window, but I want it to refresh the webpage the pop-up window was clicked on.
So the page can refresh to see that there is a valid login session for that user.
Is this possible w/ jQuery?
In your popup window:
$('#closeButton').click(function(e) {
window.opener.location.reload(true);
window.close();
e.preventDefault();
});
Reloads the parent page and closes the popup.
You can do this:
window.location.reload()
It just tells javascript to reload the page, this is not dependent on jQuery.
onclick="javascript:window.opener.location.reload(true);self.close();"
Here is a code that refresh parent window and closes the popup in one operation.
<script language="JavaScript">
<!--
function refreshParent() {
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow) {
window.opener.progressWindow.close()
}
window.close();
}
//-->
</script>
Use this code in ajaxlogin.js
file for mvc 4 user
$('#closeButton').click(function(e) {
window.opener.location.reload(true);
window.close();
e.preventDefault();
});
Its working fine
Works efficiently for me:
$(window).unload(function() {
if (!window.opener.closed) {
window.opener.__doPostBack('', '');
e.preventDefault();
}
});
Use this code in window close event like
$('#close').click(function(e) {
window.opener.location.reload();
window.close();
self.close();
});
http://www.delhincrjob.com/blog/how-to-close-popup-window-and-refresh-parent-window-in-jquery/
精彩评论