Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
117
rated 0 times [  123] [ 6]  / answers: 1 / hits: 54480  / 15 Years ago, sun, august 2, 2009, 12:00:00

I have various links which all have unique id's that are pseudo-anchors. I want them to affect the url hash value and the click magic is all handled by some mootools code. However, when I click on the links they scroll to themselves (or to the top in one case). I don't want to scroll anywhere, but also need my javascript to execute and to have the hash value in the url update.



Simulated sample code:



<a href=#button1 id=button1>button 1</a>
<a href=#button2 id=button2>button 2</a>
<a href=# id=reset>Home</a>


So if you were to click on the button 1 link, the url could be http://example.com/foo.php#button1



Does anyone have any ideas for this? Simply having some javascript return void kills the scrolling but also kills my javascript (though I could probably work around that with an onclick) but more importantly, prevents the hash value in the url to change.


More From » html

 Answers
47

I'm probably missing something, but why not just give them different IDs?



<a href=#button1 id=button-1>button 1</a>
<a href=#button2 id=button-2>button 2</a>
<a href=# id=reset>Home</a>


Or whatever convention you'd prefer.


[#99018] Monday, July 27, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaredsages

Total Points: 273
Total Questions: 97
Total Answers: 105

Location: French Southern and Antarctic Lands
Member since Fri, Jan 6, 2023
1 Year ago
jaredsages questions
;