I have some problems with the function to refresh the main page when a pop is closed.
In my popUp page I have the following javascript
$(function () {
window.onunload = function () {
if (window.opener && !window.opener.closed) {
window.opener.popUpClosed();
}
};
});
In the main page I have the following javascript
$(function () {
function popUpClosed() {
window.location.reload();
}
});
I got an error, that the object don’t support the method ‘popUpClosed’.
I saw this solution on this answer here in StackOverflow, but I don’t know how can I fix this error.
Have you tried the next answer down:
Source: Refresh parent window when the pop-up window is closed
Update
You can get a reference to a window like this:
Source: https://developer.mozilla.org/en/DOM/window.open
Update
I just realized that
window.opener.popUpClosed()is looking for thepopUpClosed()function in the global scope on the main page, but it’s not actually declared in the global scope, try this:Removing the
document.readyevent handler around this will allow it to be accessible from a child document (like a popup). Also notice the function is now declared like:var <name> = function () { ... };which allows it to be accessible via thewindowobject.