Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Close Pop-up window and refresh parent page in IE


tec4 - 8:21 am on Nov 18, 2011 (gmt 0)


Hello Everyone,

I've got some JavaScript that works well in Firefox to pop up a window... then when a link is clicked inside of the window, the pop-up is closed, the parent page is re-freshed and the offset/scrollbar of the parent page stays the same after re-freshing.

In IE, however, the pop-up does not close but the parent page re-freshes (but does not hold the same page position). Wondering if there is something I could add to make the pop-up window close in IE as well to make the script more browser compatible.

Current Code:

function close_this_window(){
//sets $pageoffset which makes parent page re-load
//and have the scrollbar rest in same position rather
//than starting back up at top of the page
$pageoffset = window.opener.document.body.scrollTop;
window.opener.location.reload();
window.opener.document.body.scrollTop = $pageoffset;
window.close();
return false;
}


//AJAX stuff etc etc then the following:

$.post('process.php', $("#myform").serialize(), function(data) {
$('#results').html(data);
if (data == "success") {

close_this_window();
}
});


trying to end the Ajax request with the close_this_window() function but not getting IE to be able to close pop up window.

Anyone know what could be preventing it from closing in IE?


Thread source:: http://www.webmasterworld.com/javascript/4388462.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com