<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<a href="#test">Test</a>
<script>
window.onhashchange = function () {
console.log(location.hash);
history.pushState('', '', '/url/');
alert(location.hash === '');
};
</script>
</body>
</html>