3

Assume I have web page http://www.albahari.com/threading/ with many text and articles in it. One of articles name is Thread Pooling. I would like to send my friend link to particular this article and not whole page from beginning. I would like construct link that scrolls down page in browser to particulate article Thread Pooling after clicking it. How to achieve that? How to find available direct links in web page?

6

To go, as an example, to the article on "Thread Pooling", use the link:

http://www.albahari.com/threading/#_Thread_Pooling

In general, look for an HTML element with the id attribute or, lacking that, the name attribute of the anchor tag at the top of the article that you want and use it, as above, after the # in the URL.

More detail

The html near the start of that particular article looks like:

<h1>
    <a name="_Thread_Pooling">Thread Pooling</a>
</h1>

<p>Whenever you start a thread, a few hundred microseconds
are spent organizing such things as a fresh private local variable stack. Each
thread also consumes (by default) around 1 MB of memory. The <i>thread pool</i> cuts these overheads by sharing and
recycling threads, allowing multithreading to be applied at a very granular
level without a performance penalty. This is useful when leveraging multicore
processors to execute computationally intensive code in parallel in
“divide-and-conquer” style.</p>

In the above, we can see:

<a name="_Thread_Pooling">

This tells us the string to use to identify the start of that article. It is what we use in the URL that points to that article.

HTML5

As grawity points out, name, which worked in HTML4, is not supported by HTML5. The id attribute should be used instead. id can be used on any HTML5 element, not just anchors.

3
  • Note that <a name=...> is old style (in fact no longer valid in HTML 5) since the same result can be achieved using the id= attribute on any tag (e.g. <h1 id="_Thread_Pooling">) and that's what most websites do nowadays. – user1686 Dec 2 '17 at 13:39
  • @grawity Thanks for that! I updated the answer to mention HTML5. – John1024 Dec 2 '17 at 18:36
  • To clarify, id= was usable for this purpose even in HTML 4 and possibly earlier versions, it's not a new addition. – user1686 Dec 3 '17 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.