Kemo
Kemo

Reputation: 7042

Replace default browser jumping to #element_id with Effect.scrollTo?

so, the thing is :

when someone clicks on a link to my website and page loads, prototypeJS is supposed to observe if there is a #elementId in the URL and stop browser from jumping to the element and do it with scrollTo().

I've seen this before but only with jQuery, but couldn't figure out how to do it with prototypeJS.

Upvotes: 0

Views: 247

Answers (2)

Sergii
Sergii

Reputation: 36

You can get rid of anchors (<a href=".." name="elementId">), so if you refer to not existing one then you page scroll gonna be just 0. You add onload listener, check if you have "#..." in url once DOM is loaded, if you do and id is valid then $('elementId').scrollTo();

Upvotes: 1

James Black
James Black

Reputation: 41858

To stop the jump in your click event handler just have return false; at the end. Jump solved.

You should have been scrolling during this time.

What have you tried to do this assignment?

Upvotes: 0

Related Questions