1

I don't know whether I am asking utter foolishness. I have a webpage, say http://www.example.com. One of its page is /test.html. It has the following layout:

Title Here

First sub heading here

lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vestibulum dolor sit amet ultrices rhoncus. Nunc at arcu eget libero auctor sodales. Morbi tristique tincidunt consequat. Donec vitae ipsum ac ligula ornare ornare eu et mi. Morbi iaculis risus ut dolor aliquam sodales. Aliquam tempor elit non tincidunt rutrum. Curabitur quis lacus at eros suscipit accumsan. Sed sit amet laoreet metus. Donec ligula lacus, vestibulum eu facilisis sit amet, malesuada a magna. Nulla sit amet malesuada augue. Nam maximus rhoncus placerat. Cras vestibulum erat in eros sodales, eu luctus elit maximus.

Second sub heading here

lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vestibulum dolor sit amet ultrices rhoncus. Nunc at arcu eget libero auctor sodales. Morbi tristique tincidunt consequat. Donec vitae ipsum ac ligula ornare ornare eu et mi. Morbi iaculis risus ut dolor aliquam sodales. Aliquam tempor elit non tincidunt rutrum. Curabitur quis lacus at eros suscipit accumsan. Sed sit amet laoreet metus. Donec ligula lacus, vestibulum eu facilisis sit amet, malesuada a magna. Nulla sit amet malesuada augue. Nam maximus rhoncus placerat. Cras vestibulum erat in eros sodales, eu luctus elit maximus.

What I am looking for is a URL which directs the user straight to the second sub heading. Something like http://www.example.com/test.html#Second_sub_heading_here. Is it possible to do this? What all things should I read to understand about permalinks?

Edit: I am looking for a solution from user end. That is, the user visits the web page and he wants to make a permalink to direct his friends to that exact portion of the page.

Community
  • 1
  • 1
Anonymous Platypus
  • 1,101
  • 4
  • 17
  • 43
  • 1
    possible duplicate of [Link to an element within the current page](http://stackoverflow.com/questions/12386212/link-to-an-element-within-the-current-page) – JJJ Apr 02 '15 at 09:27
  • 1
    The answers are for developer side. I need to do that from the user end who doesn't have knowledge about html. I shall edit the question for better understanding. – Anonymous Platypus Apr 02 '15 at 10:06
  • You can't link to arbitrary places on web sites unless they have an id set at that exact element. – JJJ Apr 02 '15 at 10:10
  • You mean like the "share a link to this answer" feature here on SO? – j08691 Apr 03 '15 at 13:23
  • @j08691 Yes. But unor answered my question. Thanks :) – Anonymous Platypus Apr 06 '15 at 07:10

2 Answers2

2

If you want permalinks to be able to link to several points on your page, do well to give each one an id.

eg.

    <div id="first">
      <p>
      to link to second Id <a href="#second">go to second Div</a>
      </p>
    </div>

    <div id="second">
      <p>
       You'd arrive here. To go to the first, use <a href="#first">Return to 
       the First One</a>
      </p>
    </div>
1

Unless the page provides links (like, for example, Wikipedia does for most articles: example, titled "Contents"):

  1. The user would have to inspect the HTML and look for an id attribute, or an a/area element with the name attribute (which would have to be near the element that should be linked to).
  2. The user would have to append the value of this attribute to the current URL, prefixed by a # (or replacing it if already such a fragment exists).

(There might be browser extensions that make finding these attributes, or even generating a link, easier. You could ask for them on Software Recommendations SE.)

If there are no such attributes for the element in question, linking to it is not possible, unless we talk about additional software installed on user’s end (e.g., an extension implementing XPointer), in which case these links would not work for users without this software.

Community
  • 1
  • 1
unor
  • 82,883
  • 20
  • 183
  • 315