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 –