javascript 刷新页面,然后转到特定的 div
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22033384/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Refresh the page and then go to a specific div
提问by msafi
How can I use javascript to reload page and go to a specific div when a button is clicked?
单击按钮时,如何使用 javascript 重新加载页面并转到特定 div?
function reloadAgreement() {
location.reload();
}
<li><a href="" onclick="reloadAgreement();">Return to Store Info</a></li>
回答by Daymon Schroeder
function gototab(reload)
{
window.location.hash = '#tab2';
window.location.reload(true);
}
Return to Store Info
返回商店信息
from here Reload page with different anchor
从这里 重新加载具有不同锚点的页面
edit:
编辑:
To clarify, the section that says "#tab2" is the 'id' attribute of the div you want the page to go to when the link is clicked.
澄清一下,“#tab2”部分是您希望页面在单击链接时转到的 div 的“id”属性。