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
Release: 2016-06-24 11:54:02
Original
865 people have browsed it

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>
Copy after login

2. Jump to the anchor point through js method

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

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template