有没有办法在没有锚点的情况下添加书签或链接到页面的某个部分? [英] Is there a way to bookmark or link to a section of a page without an anchor?

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

问题描述

有没有办法在 HTML 代码中没有锚点的情况下为 HTML 页面(我不是其作者)添加书签或链接?

Is there a 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,还会自动向下滚动到页面的某个部分以便锚标签foo"位于屏幕顶部.

Note: the destination page has an anchor tag as "foo" then bookmarking 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 anchor tag "foo" is at the top of the screen.

推荐答案

现在是 2020 年,WICG 有一个草案 文本片段,现在您可以通过将以下内容添加到哈希中来链接到页面上的文本,就像您在搜索它一样

It's the year 2020, there is a draft by WICG for Text Fragments, and now you can link to text on a page as if you were searching for it by adding the following to the hash

#:~:text=<文本链接到>

Chrome 版本 81.0.4044.138 上的工作示例:

点击这个链接 应该重新加载页面并突出显示链接的文本

Click on this link Should reload the page and highlight the link's text

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

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