【发布时间】:2010-10-26 02:13:11
【问题描述】:
在加载页面时,我希望它转到 #content 而不更改 url。
我以为我可以使用
window.location.hash = "content";
window.location.replace("#content", "");
但#content 仍然存在于网址中。
有更好的方法吗?
编辑:
也试过了
window.location.hash = "content";
window.location.replace(window.location.toString().replace("#content", ""));
但这会使浏览器陷入循环。
【问题讨论】:
标签: javascript window anchor