Currently, I am utilizing prototype to create an ajax request through an inline onclick on a link. The function is designed to display an element on the page and everything functions properly. However, there is an issue where the browser scroll bar resets to the top after each click on the link. This can be problematic as sometimes the content I wish to display is positioned lower down the page, making it invisible to the user. Although I understand that it's preferably to avoid including the onclick inline, my specific situation requires me to dynamically generate these links and then cache the HTML for faster loading. Is there a way to prevent this browser scroll reset when using an inline onclick? Below is a snippet of how my code is structured:
<a href="#" rel="nofollow" onclick="linkAjax('example')" id="word_link_example">example</a>
function linkAjax(word){
if(!making_ajax_request){
making_ajax_request = true;
new Ajax.Request('/example/test',
{parameters:{data: word},
onLoading: function(){searchLoading();},
onComplete: function(){
making_ajax_request = false;
}
});
} else { }
}