最好是name和id都是st。避免有些特殊情况
<a name="ST"></a>
普通定位方式是在地址后面加上#ST即可,现想通过JS实现定位,代码如下
window.location.hash="ST"
非js形式:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>锚点例子 </title>
</head>
<body>
<a href="#zkm">zkm </a>
<a href="#hxy">hxy </a>
1 <br>
2 <br>
3 <br>
1 <br>
2 <br>
3 <br>
1 <br>
2 <br>
3 <br>
1 <br>
2 <br>
3 <br>
1 <br>
2 <br>
3 <br>1 <br>
2 <br>
3 <br>
1 <br>
2 <br>
3 <br>
1 <br>
2 <br>
3 <br>
<a name="zkm">zkm </a>
b <br>
b <br>
b <br>
b <br>
b <br>
b <br>
b <br>
b <br>b <br>
b <br>
b <br>
b <br>
b <br>
b <br>
b <br>
b <br>b <br>
b <br>b <br>
b <br>
b <br>
b <br>
b <br>
b <br>
b <br>
b <br>
b <br>
b <br>b <br>
b <br>b <br>
b <br>b <br>
b <br>
<a name="hxy">hxy </a>
</body>
</html>
- <html>
- <body>
- <a name="top" href="#here">go here</a>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br><br><br><br><br><br><br>
- <br><br><br><br><br><br><br>
- <br><br><br>
- <br><br><br><br><br><br>
- <a name="here">aaaaaaaaaaaaaaaaaaaaaaaaaaa</a>
- <a href="#top">go top</a>
- </body>
- </html>