Anchor click and save page position?
My page has an anchor that has no link, for example:
<a href="#">Anchor</a> When I click the anchor button at the bottom of the page, the page scrolls up. I want to keep the page position if I click the link. How can i do this. (no js is better for me)
Hope I could explain.
Thanks in advance.
You still have to use JS, but you can do it inline:
<a href="javascript:void(0);">Test</a>βββββββββββββββββββββββββββββββββββββββββββ Demo: http://jsfiddle.net/7ppZT/
Alternatively, you can record an event:
$('a[href^="#"]').click(function(e) { e.preventDefault(); }); You can place anchors anywhere on the page on which you want.
<a href="#stophere">Anchor</a> <a id='stophere'>Bottom Of Page</a> Then the link will go to the named anchor. Just stick to this element wherever you stay.
to fix this problem, I use this code, this is a script solution, but works on all browsers
<a href="javascript:void(0)">Anchor</a> you need to set the name and add the name after # like this
<a name="adsf" href="#adsf">Anchor</a> <a href="#noname">Anchor</a> Make sure the noname you did not use for the id attribute for any tag or name attribute of tag a .