锚点链接
本页面内跳转
1、使用id
<a id="line1_name">the first line</a>
<a href='#line1_name'><button>Go first line</button></a>
2、使用name
<a name="line1_name">the first line</a>
<a href='#line1_name'><button>Go first line</button></a>
其他页面之间跳转
目的页面代码与上相同,要用页面代码如下
<a href='要跳到的文件名.html#line1_name'><button>Go that page</button></a>
我的案例
本页面
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>anchor</title>
</head>
<body>
<!-- id的 -->
<a id="line1_name">the first line.</a><br/>
<!-- name的,选其一即可 -->
<a name="line1_name">the first line.</a><br/>
</body>
</html>
<script type="text/javascript">
for(var i=0;i<=100;i++){
document.write("I am a study!<br/>");
}
for(var i=0;i<=0;i++){
document.write("<a href='#line1_name'><button>Go first line</button></a><br/>");
}
</script>
其他页面
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>anchor</title>
</head>
<body>
</body>
</html>
<script type="text/javascript">
for(var i=0;i<=0;i++){
document.write("<a href='锚点链接.html#line1_name'><button>Go that page</button></a><br/>");
}
</script>