• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to use Anchors on long dynamic lists?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use Anchors on long dynamic lists?


  • Subject: Re: How to use Anchors on long dynamic lists?
  • From: James Cicenia <email@hidden>
  • Date: Wed, 10 Dec 2008 07:46:02 -0600

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@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >How to use Anchors on long dynamic lists? (From: James Cicenia <email@hidden>)
 >Re: How to use Anchors on long dynamic lists? (From: Ralf Schuchardt <email@hidden>)

  • Prev by Date: Re: How to use Anchors on long dynamic lists?
  • Next by Date: many-to-many relationship and qualifiers
  • Previous by thread: Re: How to use Anchors on long dynamic lists?
  • Next by thread: Wonder: Attempting to lock editing context that was previously locked error
  • Index(es):
    • Date
    • Thread