neilcg1 Posted April 14, 2009 Share Posted April 14, 2009 Hi I am using the following script to auto refresh my web page. It works fine but the page has a scroll bar, every time it refreshes the page returns to the top and I have to scroll to the bottom again. I would like the page to refresh from the bottom without going back to the top and the need to scroll down being neccessary every time. Can anybody tell me how to achieve this please. The auto refresh script I am using is: <script type=text/javascript> // The time out value is set to be 10,000 milli-seconds (or 10 seconds) setTimeout(' document.location=document.location' ,5000); </script> Quote Link to comment https://forums.phpfreaks.com/topic/154072-auto-refresh-issue/ Share on other sites More sharing options...
JonnoTheDev Posted April 14, 2009 Share Posted April 14, 2009 Use an anchor link i.e. http://www.xyz.com/page.php#bottom At the bottom of the page <a name="bottom"></a> Quote Link to comment https://forums.phpfreaks.com/topic/154072-auto-refresh-issue/#findComment-809894 Share on other sites More sharing options...
neilcg1 Posted April 20, 2009 Author Share Posted April 20, 2009 Hi Many thanks for your reply, it was a great help. However I could do with a little more please. On reflection, I actually need the refresh to refresh at the last scroll position not the bottom of the page. Sorry for the confusion, but it was only when I applied you help that I realised it would be far better to refresh at the last scroll position. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/154072-auto-refresh-issue/#findComment-814588 Share on other sites More sharing options...
JonnoTheDev Posted April 20, 2009 Share Posted April 20, 2009 Impossible! How can you detect what portion of the page a user is reading. Depending on your page layout the amount of scroll greatly differs with screen resolution. An alternative is not to reload but use AJAX to do whatever it is you are attempting if a condition is met. Quote Link to comment https://forums.phpfreaks.com/topic/154072-auto-refresh-issue/#findComment-814639 Share on other sites More sharing options...
neilcg1 Posted April 20, 2009 Author Share Posted April 20, 2009 Hi Neil Ok thats answered that. So could you help a little further. I could well be doing something wrong, but when I used your script you provided to get the page to refresh to the bottom it did exactly that. The problem was that I have the page set to refresh every 10 seconds. So the page loaded and refreshed 10 seconds later to the bottom, which was great, but after that the 10 second refresh stopped working. So in other words it did it once and was then static and not refreshing. Quote Link to comment https://forums.phpfreaks.com/topic/154072-auto-refresh-issue/#findComment-814652 Share on other sites More sharing options...
JonnoTheDev Posted April 20, 2009 Share Posted April 20, 2009 debug the refresh script Quote Link to comment https://forums.phpfreaks.com/topic/154072-auto-refresh-issue/#findComment-815011 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.