Javascript refresh/reload while keeping viewing location of page

I've got a child popup window which performs a duty and then closes itself after refreshing the parent / opener window. The parent window happens to be quite large, and when the page gets refreshed it automatically goes to the top of the page. I'd like it to stay where the user was last looking. (like how IE performs a refresh when clicking the button).

It seems like there would be a simple answer, but perhaps not. Maybe it needs to track where the user was last scrolled to and then envoke the scrollTo(); function. I'm not sure. I need help! Please let me know your thoughts. Here's the code I'm using currently. It's quite simple.

<script language="javascript">
          window.opener.location.reload();
          top.close();            
</script>


slinkerAsked:
Who is Participating?
 
lil_puffballConnect With a Mentor Commented:
Or, even better, this is cross browser:

<script language="javascript">
          window.opener.history.go();
          top.close();          
</script>
0
 
lil_puffballCommented:
Please provide the html/javascript of the child window.
0
 
slinkerAuthor Commented:
I already have; That's pretty much the only important code in the child window. It refreshes the parent window, and closes itself.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
lil_puffballCommented:
Oh, sorry. Here, try this code:

<script>
function refreshParent(){
var temp=window.opener.document.body.scrollTop;
window.opener.location.reload();
window.opener.scrollTo(0,temp);
self.close();
}
</script>
0
 
slinkerAuthor Commented:
nope; didn't work. I tried alerting the temp variable to see what it was, and it did recieve a value (420), but the parent window didn't scroll down.
0
 
slinkerAuthor Commented:
ahh, the second one worked great. That's interesting. It seems like that would pull the page from cache, but it's not... it's a dynamic page and its got the new info. Thanks a lot.
0
 
lil_puffballCommented:
Glad to help. Thanks for the points and the A! :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.