大网数据广告活动
网站运营与故障问答

How are these URLs highlighting text?

· 52CE 我爱测

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…

问题原文

原帖链接 · 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

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2020-06-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。