How to make the browser back button disregard hash tags?

后端 未结 5 2248
温柔的废话
温柔的废话 2021-02-14 07:57

I have a website that uses hashes to open/close some tabs and layers on the current page. The reason behind using hashes is, that if a user visits another page via a link and th

5条回答
  •  说谎
    说谎 (楼主)
    2021-02-14 08:54

    Maybe prevent the default behavior and make the jump to the hash with javascript?

    $("a").click(function(event) {
      $("html,body").scrollTop($(this.hash)[0].offsetTop)
      event.preventDefault();
    });
    

提交回复
热议问题