Summary of methods for js page jump control anchor

1. The method of page jump
1.html:

<a href='跳转到的页面.html'>跳转</a>

2.js:
Open in a new page:

window.open('跳转到的页面.html')

Jump to the original page:

window.location.href='跳转到的页面.html'

Two, the method of controlling the anchor point
1.JS method:

<!--这个页面的名称为:跳转页面-->
<p id='abc'>跳转到这里</p>
//这个代码不在‘跳转页面’,可实现跨页面跳转
window.open('跳转页面.html #abc')

2.html method:

<!--这个是同一个页面跳转的,想要实现跨页面锚点可在锚的href中协商要跳转到的页面的名称-->
<a href='#btn'></a><!--点击 锚 到达 点 -->
<!--为了效果明显给中间加上一个大框占位-->
<div style='width:100%;height:800px;background:#ddd'></div>
<a id='btn'></a>
<div style='width:100%;height:800px;background:#ccc'></div>

Guess you like

Origin blog.csdn.net/isfor_you/article/details/110396835