I created a function in javascript that i add to an anchor as such
javascript :
somefunction = function () {alert(\'foo\')}
html :
The onclick causes the page to resubmit, therefore scrolling to the top.
You need the onclick event to return a false in order to avoid the postback.
This can be done by changing your function to return a false:
somefunction = function () {alert('foo'); return false;}
Or to change the link and onClick event to do so:
anchor