URL 中的 `#:~:text=` 位置哈希到底是什么? [英] What exactly is the `#:~:text=` location hash in an URL?
问题描述
今天我注意到 Google 上的一些搜索给了我指向结果的链接,其中包含突出显示文本的明显说明.
Google 带我到
我进一步试验了一下,这似乎是 Google Chrome 的一个功能.如果将 #:~:text=something
附加到 URL,它会突出显示页面上的文本.
text
这个词加上不同的字符很难用谷歌搜索,所以我找不到关于这个主题的任何东西.
要了解有关此类URL 黑客"的更多信息,请参阅我想知道:
谷歌浏览器的这项功能叫什么?
Scroll To Text Fragment
好的,在朋友的帮助下,同时通过来自
突出显示整段文本
您可以使用 #:~:text=
突出显示整个文本部分.
示例:
更高级的技术
- 前缀和后缀如示例在存储库中建议的建议 https://en.wikipedia.org/wiki/Cat#:~:text=Claws-,Like%20almost,the%20Felidae%2C,-cats 提议的文本似乎对我不起作用(但? 我使用 Chrome 83).
- 您可以使用 CSS
:target 设置突出显示文本的外观
并且您可以选择退出您的网站,因此此功能不适用于再说了.
Today I noticed that some searches on Google gave me links to results with apparent instructions to highlight text.
Google brought me to What is the maximum size of a zip file on Windows 10 Pro 64...:
I experimented a little bit further and this seems to be a feature of Google Chrome. It highlights text on the page if you append #:~:text=something
to the URL. https://example.com/#:~:text=domain seems to work fine, but only on Chrome (Chrome Beta on the left, Firefox on the right).
The word text
together with different characters is a bit hard to google, so I couldn't find anything on the subject.
For finding out more information about these kinds of "URL-hacks" I want to know:
What is this feature of Google Chrome called?
Scroll To Text Fragment
OK, with the help of a friend and at the same time via a comment from Berto99 I found it:
Apparently this is a feature called Scroll To Text Fragment. It is enabled by default since Chrome 80, but apparently not yet implemented in other browsers.
There are quite nice examples in the "W3C Community Group Draft Report". More good examples can be found on Wikipedia.
Highlighting the first appearance of a certain text
Just append #:~:text=<text>
to the URL. The text search is not case-sensitive.
Example: https://example.com#:~:text=domain
Highlighting a whole section of text
You can use #:~:text=<first word>,<last word>
to highlight a whole section of text.
More advanced techniques
- Prefixing and suffixing like the example suggested in the repository for the suggestion https://en.wikipedia.org/wiki/Cat#:~:text=Claws-,Like%20almost,the%20Felidae%2C,-cats texts as proposed don't seem to work for me (yet? I use Chrome 83).
- You can style the look of the highlighted text with the CSS
:target
and you can opt your website out so this feature does not work with it anymore.
这篇关于URL 中的 `#:~:text=` 位置哈希到底是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!