The child lost its parent!!
I have a parent window, when somebody clicks on an image a JS popup opens and displays the photo and its information.
To close the popup/child window, and to flash an element on my parent/opener window, I have been using this function:
function closeWindow() {
var currentID = document.getElementById('currentID').value;
window.opener.flashElement(currentID);
window.close();
}
My problem is this doesn't work if my users navigate away from the page that the popup originally opened. For example, in the popup window, there are next and previous buttons to scroll through the individual photos in that set of results, which reloads the page with a new querystring value.
If my user scrolls (reloads page) less than 7 times it's okay but if they scroll more than that, the window.opener
function does not work, and because of that, the window.close
function doesn't either!
I could probably rebuild the page so the data comes via an AJAX call, rather than reloading the page, but that's a lot of work I could do without.
Any ideas?
The child lost its parent!!
I have a parent window, when somebody clicks on an image a JS popup opens and displays the photo and its information.
To close the popup/child window, and to flash an element on my parent/opener window, I have been using this function:
function closeWindow() {
var currentID = document.getElementById('currentID').value;
window.opener.flashElement(currentID);
window.close();
}
My problem is this doesn't work if my users navigate away from the page that the popup originally opened. For example, in the popup window, there are next and previous buttons to scroll through the individual photos in that set of results, which reloads the page with a new querystring value.
If my user scrolls (reloads page) less than 7 times it's okay but if they scroll more than that, the window.opener
function does not work, and because of that, the window.close
function doesn't either!
I could probably rebuild the page so the data comes via an AJAX call, rather than reloading the page, but that's a lot of work I could do without.
Any ideas?
Share Improve this question edited Dec 23, 2011 at 1:26 user596075 asked Dec 23, 2011 at 1:05 TheCarverTheCarver 19.7k27 gold badges103 silver badges153 bronze badges 7 | Show 2 more comments1 Answer
Reset to default 17My guess is that
window.opener.flashElement(currentID);
is throwing an error, or the function does not exist. Most likely the element with the value of currentID does not exist on the page. Try catching the error.
function closeWindow() {
var currentID = document.getElementById('currentID').value;
try {
window.opener.flashElement(currentID);
} catch (err) {
alert(err.description || err) //or console.log or however you debug
}
window.close();
}
closeWindow()
function being called? When the user clicks a "close" button or something similar? And just to be totally clear,closeWindow()
is in the child window, correct? – Drew Gaynor Commented Dec 23, 2011 at 1:31