Reputation: 15357
The default way to jump to somewhere in a HTML page is use the a href/a name tags. However, if I want to refer to an external website, somewhere in the middle and that external page does not use the a name tag, is there an alternative way? Like jumping to the first occurrence of some text?
Upvotes: 0
Views: 39
Reputation: 4378
If one of the elements on the site which your are trying to link to has an id attached to it.
You can force the load of the page onto that specific element by adding a hashtag at the end of the url of the website, and the name of the id for that specific element.
For example:
<a href="https://yourdomain.com/page#element_to_jump_to">Click me!</a>
Try clicking this clicking this link just here:
Link to a part inside an external HTML page
You will notice that it brings you to the footer section of this StackOverflow
post.
However, other than that there are no other possible ways of achieving this (at least as far as Google knows)
Upvotes: 1
Reputation: 43479
It's only possible if you find element with ID at the place of where to jump, than simply apply #id-of-element
to link.
E.g. We have this HTML attributes list and want to link to lang
attribute.
Inspect element and we find <dt id="attr-lang">
than link would be https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#attr-lang
Upvotes: 1
Reputation: 167182
You really don't need a:
<a name="named-anchor"></a>
Find the nearby element with an id
attribute. For eg., consider this:
https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04
The site has:
<h2 id="prerequisites">Prerequisites</h2>
So you can go to that place, by adding #
and the id
value:
https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04#prerequisites
If that's not there, then it is not possible.
Upvotes: 1
Reputation: 6040
Not possible unless the external website has any custom support for it and they don't have name
or id
in the desired location.
Upvotes: 2