页面中的两种锚标记定位方式——a和location.hash

来源:互联网 发布:霹雳布袋戏软件 编辑:程序博客网 时间:2024/05/08 18:42

<a href="#test">点击锚</a>...<a name="test">到标记</a>

这是最简单的锚标记的方式,在网页中可能由于篇幅过大所以很长,那么想回到某个位置就可以用这种方式定位。

还有种是用javascript

<script>function move(){location.hash="#there";}</script><div onclick="move()">GO</div>...<div id="there">there</div>

利用
location.hash="#there";

定位,不过明显没有a来的方便,不知道这个hash还有没有其他的用处