Solved

Javascript refresh/reload while keeping viewing location of page

Posted on 2004-03-27
7
690 Views
Last Modified: 2011-04-14
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>


0
Comment
Question by:slinker
  • 4
  • 3
7 Comments
 
LVL 12

Expert Comment

by:lil_puffball
Comment Utility
Please provide the html/javascript of the child window.
0
 

Author Comment

by:slinker
Comment Utility
I already have; That's pretty much the only important code in the child window. It refreshes the parent window, and closes itself.
0
 
LVL 12

Expert Comment

by:lil_puffball
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 12

Accepted Solution

by:
lil_puffball earned 125 total points
Comment Utility
Or, even better, this is cross browser:

<script language="javascript">
          window.opener.history.go();
          top.close();          
</script>
0
 

Author Comment

by:slinker
Comment Utility
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
 

Author Comment

by:slinker
Comment Utility
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
 
LVL 12

Expert Comment

by:lil_puffball
Comment Utility
Glad to help. Thanks for the points and the A! :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now