单击后退按钮时,使浏览器忽略URL哈希
例如,如果用户在http://example.com上 ,则用户转到http://example.com#comments 。 如果用户在浏览器上单击“返回”,我怎样才能让他“忽略” http://example.com并直接转到他之前访问过的url?
我加载了jQuery。
而不是像以下链接:
Link
使用location.replace()
在浏览器的历史记录中“覆盖” http://example.com
的记录。
https://developer.mozilla.org/en/DOM/window.location
例:
HTML:
Link
JavaScript的:
$("#commentsLink").click(function(){ window.location.replace("#comments"); });