Ah --

Thanks for this. I wasn't thinking javascript. This will definitely help.

James


On Dec 10, 2008, at 5:55 AM, Ralf Schuchardt wrote:


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 protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to