2016-01-24 47 views
1

我目前在一个网址像这个 -使用Javascript - 页面重载不与散列值工作

http://localhost:8000/settings#social_accounts

我要重新加载这个页面JS/jQuery,这样我可以有我确切的URL与散列。

所以我做了什么是 -

路1

location.reload(); 

路2 -

location.reload(true); 

方式3-

window.location.replace(window.location.href); 

路4-

window.location.href += window.location.hash; 
location.reload(window.location.href); 

但没有任何工作。每天的这个4路是给我一个重定向到

http://localhost:8000/settings

但我想重定向URL - http://localhost:8000/settings#social_accounts

任何人都可以请帮助?

+0

使用window.location.href,所以window.location.href = window.location.href –

+0

这是奇数行为' location.reload()'工作正常**如果浏览器首先请求URL为has,而不是用历史记录API修改URL –

+0

您是否拥有#social_accounts id的div? –

回答

0

我已经解决了它喜欢这 -

window.location.replace(window.location.href + '#' + window.location.hash.substr(1));

相关问题