Organizational Research By

Surprising Reserch Topic

how to modifying document location hash without page scrolling using by javascript

modifying document location hash without page scrolling  using -'javascript,jquery,fragment-identifier'

We've got a few pages using ajax to load in content and there's a few occasions where we need to deep link into a page. Instead of having a link to "Users" and telling people to click "settings" it's helpful to be able to link people to user.aspx#settings

To allow people to provide us with correct links to sections (for tech support, etc.) I've got it set up to automatically modify the hash in the URL whenever a button is clicked.  The only issue of course is that when this happens, it also scrolls the page to this element.

Is there a way to disable this?  Below is how I'm doing this so far.

    //This emulates a click on the correct button on page load
     $("#buttons li a").removeClass('selected');

    //Click a button to change the hash
    $("#buttons li a").click(function(){
            $("#buttons li a").removeClass('selected');
            //return false;

I had hoped the return false; would stop the page from scrolling - but it just makes the link not work at all. So that's just commented out for now so I can navigate.

Any ideas?

asked Sep 16, 2015 in JAVASCRIPT by vibhorsingh
recategorized Sep 16, 2015 by rajesh
0 votes

Related Hot Questions

Government Jobs Opening