Return to Snippet

Revision: 22049
at December 29, 2009 17:18 by shapeshifta


Initial Code
document.observe("dom:loaded", function() {
if ($$('a.scroll_me')) {
	$$('a.scroll_me').invoke('observe','click', function(event) {
		Event.stop(event);
		var elementLink = Event.element(event).readAttribute('href');
		var scrollHere = elementLink.substr(1, elementLink.length); 
		Effect.ScrollTo(scrollHere);
		return false;
	});
}	
});

Initial URL


Initial Description
use an anchor like this: <a class="scroll_me" href="#main">...
scriptaculous needed ;)

Initial Title
Smooth anchor scrolling using prototype and scriptaculous unobtrusive with href attribute

Initial Tags


Initial Language
JavaScript