Does anyone know how I can create a deeplink to a subsection of an individual webpage?
Wiki seem to have it cracked but I can't seem to find the answers anywhere on the web.
PS keep it simple!
Linking to a specific location or element on a page is possible only if the destination contains markup that constitutes a “destination anchor” that you can use in a fragment identifier (starting with #
) in a link. The following create such anchors:
- An
id
attribute (on any element) - A
name
attribute on ana
element
The former is the modern, preferable way and lets you refer to an element, not just a location (point) or just an inline element. For example, if the destination page http://www.example.com/stuff.html contains
<div class="section" id="sec7">
<h2>Foo bar</h2>
<p>Some text.</p>
Any other content
</div>
then you can use a link like
<a href="http://www.example.com/stuff.html#sec7">Foo bar</a>
Suppose you wanted to begin a document with a table of contents that would link people to text that appear s later in the document. Your index would include the following:
<a href="#pt1">Part I</a> <a href="#pt2">Part II</a>
Later in the document, you will include the following tags:
<a name=pt1></a> and <a name=pt2></a>
Reference: Links and Anchors
EDIT:
Where ever you want to insert a link, write this:
<a href="http://yourpage.com#pt1">Part I</a>
Here http://yourpage.com
would be replaced by the actual url to your page. Now in the code for your page, insert a tag at the point that you want your link to point to.
<a name=pt1></a>
来源:https://stackoverflow.com/questions/12510027/how-do-i-create-a-deeplink-to-a-subsection-of-a-webpage