有没有办法书签或链接到没有锚点的页面的一部分? [英] Is there any way to bookmark or link to a section of a page without an anchor?

查看:164
本文介绍了有没有办法书签或链接到没有锚点的页面的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以书签或链接到HTML页面(我不是作者)而没有html代码中的锚点吗?

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.

注意:目标页面有一个锚标记为foo然后书签如 http:/ ... hello.html#foo 不仅会将用户带到hello.html,还会自动向下滚动到页面的一部分,以便anchore标签foo位于屏幕的顶部

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

推荐答案

你只需要拥有在元素上使用适当的id属性,就像书签一样...

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>

参见 W3C规范:具有 id 属性的锚点

较旧的规范还允许基于 name 属性进行导航,但此属性已从最新的HTML规范中删除(但如果有 name 属性可以与 id 属性相同的方式使用。

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).

如果您希望导航到的 id name 属性,则没有导航到页面内特定点的方式,仅导航到页面本身。在这种情况下,您可能需要引用相关信息并提供带有链接的引文,或者可能询问作者是否会添加 id

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.

这篇关于有没有办法书签或链接到没有锚点的页面的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆