Ancor不能与javascript一起使用。Anchor不能与javascript一起工作
当我使用URL加载我的页面时,锚点起作用。 当我把它作为例子设置它。页面正在加载,但锚点不起作用。 (顺便说一句:为了我的目的,它的姊妹重新加载发生)。
这里我的脚本(评论什么,我想)..和actualy我想更多...
function hash_test() {
href = window.location.href;
alert(href);
if (href.lastIndexOf('#') > 0){ //remove hash if present
href = href.substring(0,href.lastIndexOf('#'));
}
alert(href);
/* window.location.href = href;
window.location.hash = '#beitrag9';*/ // does not work to
window.location.href = href +'#beitrag9';
window.location.reload(true);
}
此锚应该完成什么? – Harangue
你是否从你的代码中调用了'hash_test()'函数? –
为什么页面需要重新加载?没有这些信息,这听起来像一个XY问题http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem –