Is there any way to bookmark or link to a section of a page without an anchor?

Is there any way to bookmark or link to an HTML page (which I am not author of) without having an anchor in the html code ?

I want the page to get scrolled down to a particular section when accessed from a bookmark or hyperlink even if there is no anchor tag in the destination page.

Note : the destination page has an anchor tag as "foo" then bookmark like http:/...hello.html#foo will not only take the user to hello.html but also automatically scroll down to the section of the page so that the anchore tag "foo" is at the top of the screen


You only need to have the appropriate id attribute on an element to use it like a bookmark...

<a href="#test">Test</a>

...

<p id="test">Hello world</p>

See the W3C specification: Anchors with the id attribute

Older specifications also allowed navigation based on the name attribute, but this attribute has been removed from the latest HTML specifications (but if there is a name attribute it may be used in the same way as an id attribute).

If there is no id or name attribute where you wish to navigate to, there is no way of navigating to the specific point within the page, only to the page itself. In this case you may want to quote the pertinent information and supply a citation with a link or perhaps ask the author if they would add an id .


如果一切都失败了,你可以使用从window.location获取查询,使用jQuery来获取DOM元素,请求它的位置并且scrollTop在那里移动(参见jQuery滚动到元素)


The Firefox extension "Web Marker" does exactly what you want.

https://addons.mozilla.org/en-US/firefox/addon/web-marker/

You can find its source code and documentation here:

http://liveurls.mozdev.org/tech.html

链接地址: http://www.djcxy.com/p/88982.html

上一篇: 获取链接以转到其他页面上的特定部分

下一篇: 有没有任何方法来书签或链接到一个页面的一部分没有锚点?