homepage Welcome to WebmasterWorld Guest from 54.161.247.22
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Close Pop-up window and refresh parent page in IE
tec4




msg:4388464
 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?

 

enigma1




msg:4389797
 12:26 pm on Nov 22, 2011 (gmt 0)

Where is the code that opens the popup window? I tried the popup code here I don't see a problem on IE, what I did I created a popup window and then used the close_this_window() function. Other than declaring the $pageoffset var before using it, I could not see a problem. The popup was closed as expected.

Any js errors that show up when you run it on IE?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved