简体   繁体   中英

How to put relative path anchor

I need to implement skip link so I do:

<a class="sr-only sr-only-focusable" href="#footer" target="_self">Footer</a>

supposed to have this link http://localhost/example . I want when the use click on the link this:

http://localhost/A#footer

but now I obtain this link http://localhost/#footer and it gives me 404. Anyone can help me?

An anchor is a link to an element id inside a specific file

<div id="MyDiv">...</div>

To go to the anchor "MyDiv" in example.html you should go to :

http://localhost/example.html#MyDiv

In your case, you need a <div id="...."> for call your page.
After it, you can call them with #idpath in <a href="../index.html#idpath">Go To Path</a>

For Example Above

 <html> <body> <a href="#yourpage3">Go to Page 3</a><br><br> <div id="yourpage1"> <h1>Page Load 1</h1> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> <div id="yourpage2"> <h1>Page Load 2</h1> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> <div id="yourpage3"> <h1>Page Load 3</h1> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </body> </html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM