-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Text Fragments in AMP #32139
Comments
Since the fragment directive (everything including and after I believe the AMP viewer displays the content in an iframe? If so, that's the reason we don't get text highlighting, to enforce origin isolation, text fragments only work in the main frame. I think the most promising solution would be to expose information about the text fragment to the page (see WICG/scroll-to-text-fragment#128) and have the root AMP page pass through the data to the iframe'd content. IIRC, AMP actually had an implementation of scroll-to prior to text-fragment support in the browser, that could be reused (though the matching algorithm may need to be updated to support the text-fragment semantics). Alternatively, there is an open source implementation of the text-fragment spec (see WICG/scroll-to-text-fragment#135) that we could probably pull in. Could someone on the AMP side comment on the feasibility of this approach (+confirm my assumptions above)? |
@bokand I haven't had a chance to look into this in depth. Plan to start looking next week and will comment when I have something. |
@bokand fragment directives are still accessible, albeit in a slightly-convoluted manner. See WICG/scroll-to-text-fragment#128 (comment) for some utils that can help web devs interoperate with these directives. |
Closing this issue as it is now verified using Chrome >= 93. |
Describe the new feature or change to an existing feature you'd like to see
Chrome has implemented this new W3C draft spec about Text Fragments that allows linking to specific parts of a web page. Upon opening the link the browser will scroll-to and highlight the specified section.
While this works on most sites, one big issue with the feature currently is that it doesn't work on AMP pages. For example, the text fragment anchor part of the URL seems stripped from most AMP pages when loaded. From my understanding of AMP, there might be other issues even if the fragment was not stripped.
Some examples:
There seems to be a way to make this work since some pages loaded from a search results page work (e.g. search for "when is ios 14.3 coming out")
Would it be possible to add support for scroll-to text fragments?
The text was updated successfully, but these errors were encountered: