Home >Web Front-end >HTML Tutorial >【html】Some things about anchor points_html/css_WEB-ITnose

【html】Some things about anchor points_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:54:02881browse

Today I modified the guild system and used anchor points to control the page position. As a result, I encountered some problems and solved them by querying relevant information. I will summarize them here.

Two methods to jump to the anchor point:

1. Add the name attribute and id attribute to the anchor point. Generally, you only need to add the name, and the id is added for compatibility with other browsers.

<a name="a1" id="a1"></a>

2. Jump to the anchor point through js method

var _id = location.href.split('#')[1];if(_id){    document.getElementById(_id).scrollIntoView(true);}

PS: generally just use name and id , if you can't solve it, try using js.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn