:
history.pushState("", document.title, window.location.pathname);
…,或者,如果您想维护搜索参数:
history.pushState("", document.title, window.location.pathname + window.location.search);
:
var loc = window.location.href,
index = loc.indexOf('#');
if (index > 0) {
window.location = loc.substring(0, index);
}
…但这为您刷新了页面,刚到达那里似乎有点不礼貌。咧着嘴笑,似乎是最好的选择。