Use of anchor in html, and use of html
Now let's summarize several situations of controlling the anchor:
1. On the same page
[Html] view plaincopy
<A name = "add"> </a> <! -- Define the anchor -->
<A href = "# add"> jump to add </a>
2. In different pages, the anchor is located in a.html and jumped from the link of another page to this anchor.
[Html] view plaincopy
<A href = "a.html # add"> jump to a. add </a>
3. Click the link to trigger the js event and jump to the anchor. There are two processing methods:
First:
[Html] view plaincopy
<A href = "# add" onclick = "add ()"> triggers the add function and jumps to the add anchor. </a>
Second:
[Html] view plaincopy
<Div id = "divNode"> <! -- Contents --> </div> <! -- Assume a node to jump to -->
<A href = "#" onclick = "document. getElemetnById ('divnode'). scrollIntoView (true); return false;"> achieve anchpoint effect through scrollIntoView </a>
There are several methods to set the anchor location in html, such as id location, name location, and js location. These methods are not necessarily the most complete. You can refer
1. Locate by id:
<A href = "# 1F" name = "1F"> ANCHOR 1 </a> <div name = "1F"> <p> 11111111111 </br> 11111111111 </br> 11111111111 </br> 11111111111 </br> 11111111111 </br> </p> </div>
Such positioning can be targeted at any tag.
2. Locate using name:
<A href = "# 5F"> anchor 5 </a> </br> </br> </br> <a name = "5F"> 1111111
The name attribute can only be used to locate tags a, but it cannot be used to locate tags such as div.
3. Use js to locate
<li class="" onclick="javascript:document.getElementById('here').scrollIntoView()"></li>
Instance:
Smooth js anchor Positioning
<! Doctype html public "-// W3C // dtd html 4.01 // EN">