I've a query: is it possible to disabled browsers default action on links such as this example?
I am not talking about disabling click event on Anchor tag( PART 123) using event.preventDefault()
What I am trying to do : There is TOC at the beginning of page with name links (#part-) to different part of page. I can easily disable click event on each link using :
$("a.namedLink").click(function(event) {
event.preventDefault();
//and do whatever I want to, like animated scroll then moving the dock-able header using jQuery Affix plugin
});
But, if someone copies the link or directly opens it by using the URL itself (link), the code above won't work because nothing has been clicked.
I've checked couple of examples, but, they all talk about same page and #click event, like this Stackoverflow thread Scroll to a div using jquery and others:
Please let me know if we can do it and more importantly, if we should do it.
Thanks