Re: How to use Anchors on long dynamic lists?
Re: How to use Anchors on long dynamic lists?
- Subject: Re: How to use Anchors on long dynamic lists?
- From: Ralf Schuchardt <email@hidden>
- Date: Wed, 10 Dec 2008 12:55:58 +0100
Am 09.12.2008 um 19:26 schrieb James Cicenia:
I was wondering how to keep my long lists, after refresh, from
moving back to the top of the page.
This is really annoying to our customers who have long lists.
When submitting the form I use javascript to store the current scroll
position in two hidden fields and then add an onload-event to scroll
to those positions.
If you have no form but element IDs or names you could use something
like this:
function scrollToElementWithName(elementName) {
var element = document.getElementsByName(elementName)[0];
scrollToElement(element);
}
function scrollToElementWithID(elementID) {
var element = document.getElementById(elementID);
scrollToElement(element);
}
function scrollToElement(anchor) {
var coords = {x: 0, y: 0 };
while (anchor) {
coords.x += anchor.offsetLeft;
coords.y += anchor.offsetTop;
anchor = anchor.offsetParent;
}
window.scrollTo(coords.x, coords.y);
}
and call scrollToElementWithID as in an onload-event.
Ralf
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden