views:

54

answers:

2

Hey community,

I want to create an navigation with anchors. By clicking on a navigation link, the whole visible page should scroll down to the clicked anchor.

The most important is the following structure of the page.

--------------- (Begin visible browser area)
NAV1 nav2 nav3

content
--------------- (Begin/end visible browser area)
nav1 NAV2 nav3

content
--------------- (Begin/end visible browser area)
nav1 nav2 NAV3

content
--------------- (end visible browser area)

Finally all content is in a single document and the height of the current page (selected by the nav-item) has to be calculated (with a JS Library). I prefer PrototypeJS/Scriptaculous and jQuery.

The scroll effect should be a smooth slide/ effect.

Chris

A: 

See: Effect.ScrollTo

<a href="javascript:// scroll" onclick="Effect.ScrollTo('element_id', { duration:'.5'})" />link</a>
Diodeus
I think you have to read my question again.Its not only the anchor-to-anchor-scroll-effect included in my topic/question. Another important thing is that your scroll-to-anchor has to be set "dynamically", because the next page has to begin in the not visible area of your browser (see the sketch in my post).
ChrisBenyamin
+3  A: 

If you want a jQuery solution, use ScrollTo, and if all you need is anchor-based animations implement the associated LocalScroll plugin.

If you want the content panes to take up the entire visible browser area, you can set that dynamically at page load (and on browser resize) with jQuery as well. There's a great explanation of the "height" method here.

Andrew