问题原文
原帖链接 · jvriesem · CC BY-SA 4.0
I've noticed some web URLs link to a web page with highlighted text. This appears to be controlled by an escape sequence in the URL of the form #:~:text=StartText,EndText, where StartText indicates where on the page to begin the highlighting and EndText is where on the page to terminate the highlighting.
Examples
- https://www.addictivetips.com/internet-tips/select-to-highlight-text-on-web-pages-share-via-url-chrome/#:~:text=Highlighter%20Pen%20For%20Web,paste%20to%20emails%20and%20chat
- https://en.wikipedia.org/wiki/Intraclass_correlation#:~:text=In%20statistics%2C%20the%20intraclass%20correlation,same%20group%20resemble%20each%20other.
I've seen query strings and named anchors/fragments in URLs (as per standard URL syntax), but I've never seen escape sequences in URLs -- certainly not like this.
What API/standard/protocol/etc. defines/permits/governs this highlighting behavior?
Bonus points for addressing how portable this is. (It works on Google Chrome, but doesn't work in Apple's Safari for macOS.)
已采纳解答
原帖链接 · Maximillian Laumeister · CC BY-SA 4.0
This is called Scroll To Text Fragment, and arrived in Chrome 80.
Here is the draft specification, and the original proposal.
It seems to me that this is another feature that Google just added to Chrome without other browser vendors signaling any interest (like Portals, though that one never graduated from being a flag). Here is an article that calls Scroll To Text Fragment "controversial".
Scroll To Text Fragment is currently available only in Chrome and other Chromium browsers (e.g. the new Edge).
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
