Link to home
Start Free TrialLog in
Avatar of mikezang
mikezang

asked on

How scroll to old position after refresh page?

I have a page  including a folder tree, after I clcik on one folder, it will redraw by window.write, I hope that I can scroll to old position before redraw, what can I do?
I tried top.treeFrame.window.document.body.scrollTop, then use top.treeFrame.scrollTo(), but they ddin't work.
Avatar of Dopeman
Dopeman

try setting an ancor in a variable
and write this into your file where you want to go
<?php

$gohere = "<a name=\"#oldposition\">oldposition</a> ";
echo $gohere;
?>

and if you reload your page call it like this:

 yourpage.htm#oldposition

to jump to the ancor
Avatar of mikezang

ASKER

You know that I can't use ancor because the page is created by javascript, i only can use javasscript method, for example, scroll and so on, can you help me?
How can I get the original scroll position ?
I found a strange method to solve my problem, it is ok if I used two times as below,
top.treeFrame.window.scrollTo(0, 0);
top.treeFrame.window.scrollTo(0, topY);

But if only one time is executed, it doesn't work, can you explain to me?
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
Avatar of PashaMod
PashaMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial