A-HTML錨點(diǎn)定義:
設(shè)置錨:
<a href="#mao" rel="external nofollow" >&nsbp;</a>
設(shè)置點(diǎn):(為了瀏覽器兼容性,id和name一起設(shè)置)
<a id="mao" name="mao">跳至第一個(gè)錨點(diǎn)</a>
B:使用JS模擬錨點(diǎn)跳轉(zhuǎn):
js中l(wèi)ocation.href可以跳轉(zhuǎn)至某個(gè)url;
1、window.location.href = window.location.href + "#mao";
2、window.location.hash = "#mao";
備注:hash只會(huì)在跳轉(zhuǎn)到此頁面的第一次起作用,再次刷新此頁面將不起作用,而href始終起作用
以上這篇使用JS模擬錨點(diǎn)跳轉(zhuǎn)的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持錯(cuò)新站長(zhǎng)站。
新聞熱點(diǎn)
疑難解答
圖片精選