[JavaScript] ページリンクアンカー消す方法

1 min read
hiroweb developer

リンクアンカーとは

簡単に言うと、#以降の文字列

https://b.0218.jp/#link_anchor

JavaScriptで消す

以下のコードで消すことができる。

window.history.replaceState(null, '', location.pathname + location.search);