I previously tried the following two statements and it didn't work (at least on Firefox):
history.pushState({}, 'null', window.location.pathname);
window.location.href.substr(0, window.location.href.indexOf('#'));
The trick is to use this instead:
window.location.hash = '';
The problem only exists if we're trying to clear the :target
selection through JavaScript. Anchor tags with non-existing or empty hashes works: http://jsfiddle.net/SMbsb/3/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…