Solved

Javascript refresh/reload while keeping viewing location of page

Posted on 2004-03-27
7
693 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 12

Expert Comment

by:lil_puffball
ID: 10698495
Please provide the html/javascript of the child window.
0
 

Author Comment

by:slinker
ID: 10698678
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
ID: 10698738
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Accepted Solution

by:
lil_puffball earned 125 total points
ID: 10698748
Or, even better, this is cross browser:

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

Author Comment

by:slinker
ID: 10698756
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
ID: 10698778
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
ID: 10698784
Glad to help. Thanks for the points and the A! :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

756 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