1,在页面添加location.hash可实现无论哪个页面跳到该页面都跳到固定位置。
<script language="JavaScript">
location.hash="#navBar";</script>
<html>
<head>
</head>
<body>
<div id="navBar">
</div>
</body>
</html>
2,如果是点击跳转到本页某位置,<a href="#锚点id"></a>
3,如果是点击跳转到其它页某位置,<a href="lindex.html#锚点id"></a>
本文转载自:http://blog.youkuaiyun.com/liu__hua/article/details/38554955
可以做一个直观的实验,使用F12 可以查找本文html元素中有一个id是 btnDigg
你试着访问下 点击打开链接,页面自动跳到锚点位置 http://blog.youkuaiyun.com/bestcxx/article/details/52832226#btnDigg