Brian Tucker
Brian Tucker

Reputation: 310

Maintain vertical scroll position only using CSS and HTML

Is there a way to maintain my scroll position when clicking on a link which references href="#"? I know I can use Javascript to keep the current window posiiton but I'd like to know if there is a way to do it within CSS and HTML.

SOLUTION: Add return false; to the end of the JavaScript click function. This prevents the <a href="#"> from actually trying to link to #, making it so the page doesn't need to reload on click, even though the rest of the function executes.

Upvotes: 0

Views: 823

Answers (1)

Neil
Neil

Reputation: 55392

Presumably this link exists solely to support a click handler, in which case said handler should be preventing the link's default effect (which is to scroll the page).

Upvotes: 1

Related Questions