Skip to content

Instantly share code, notes, and snippets.

@shanewholloway
Created February 2, 2023 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanewholloway/fcfb10272f24bb352d3dc9544c217148 to your computer and use it in GitHub Desktop.
Save shanewholloway/fcfb10272f24bb352d3dc9544c217148 to your computer and use it in GitHub Desktop.
Search a page using text-fragment in the URL hash.
// See https://web.dev/text-fragments/
// location.hash = searchFragment('text to find in page')
export const searchFragment = txt => `#:~:text=${encodeURI(txt)}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment