Script to maintain scrollbar position

  HighTower 13:27 07 Aug 2008
Locked

Hi folks,

I'm looking for a script that will keep the scrollbar on the browser where it is as the user advances to the next page.

Anyone any ideas?

Thanks.

  Kemistri 16:11 07 Aug 2008

By your brief description, would I be right in guessing that you want visitors to move from a link on one page to a particular section or point on another page? If that's the case, why not just link to an anchor and place that anchor exactly where you want it?

  HighTower 17:00 07 Aug 2008

To be honest, what I really want is something that will remember the location of the scrollbar on an iframe so that when the page is refreshed and database content pulled in the iframe content stays in the position it was. There are a number of items in the iframe to choose from, and I don't want this to go back to the top of the list.

I know - iframes are awful (especially for any form of navigation) and I advised against it, but it's what a customer wants I'm afraid!

Thanks for your reply.

  Kemistri 18:04 07 Aug 2008

Right, so you actually want it to affect the same page on postback. I have never had this come up before.

I thought that it might be doable with JS, but I couldn't think of exactly how. A search came up with a lot folk wanting know the same thing, but not a lot of solid solutions. A possible JS solution is at click here, but I don't know if you can make that work for your exact need as that guy wasn't using an iframe.

You can do it with ASP.net 2 apparently, but I'm guessing that is irrelevant if, like me, you use PHP instead! For your situation, I can see that anchors won't really cut it as you would have to manipulate the URL and the page would bounce around a bit.

  HighTower 22:50 07 Aug 2008

Yes, I had seen a few things around but I don't like a lot of the solutions as they seem to be browser dependent, and it would be just my luck that a solution for IE7 is found that doesn't work on Firefox and that does something completely different on IE8 when it appears. I too use PHP / mySQL so ASP.net isn't really viable.

Thanks for your input, I think I would be better off spending the time coming up with a different solution rather than pursuing this one!

  nelsondawson 11:24 01 Dec 2008

Hello,

I was just reading through your post and was wondering if you have come up with a solution to this as I have a same problem where values are constantly updated from the database and the page needs to keep put on the position of the scroll.

Please do let me if you did find a solution to the problem.

Regards
Nelson Dawson

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Xiaomi Mi Mix 2 review

What went wrong at the Designs of the Year 2017

iPhone X news: Release date, price, new features & specs

Comment regarder des séries et talk-shows américains en France ?