• 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: 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


  • Follow-Ups:
    • Re: How to use Anchors on long dynamic lists?
      • From: James Cicenia <email@hidden>
References: 
 >How to use Anchors on long dynamic lists? (From: James Cicenia <email@hidden>)

  • Prev by Date: Re: PDF generator/converter
  • Next by Date: Re: How to use Anchors on long dynamic lists?
  • Previous by thread: How to use Anchors on long dynamic lists?
  • Next by thread: Re: How to use Anchors on long dynamic lists?
  • Index(es):
    • Date
    • Thread