Clearing URL hash

后端 未结 3 1076
难免孤独
难免孤独 2020-12-13 18:54

Visit stackoverflow.com/#_=_ and window.location.hash evaluates to #_=_. Fine.

Now execute window.location.hash = \'\'

3条回答
  •  猫巷女王i
    2020-12-13 19:32

    To answer the second question (removing the # without a page refresh):

    history.pushState('', document.title, window.location.pathname);
    

提交回复
热议问题