• by lolinder on 10/25/2024, 1:30:54 PM

    Today I learned that Firefox finally implemented these! They don't mention this in the article, but that's new this month—for the longest time Chrome supported it but it isn't in the standard and Firefox didn't include it. Safari got it 2 years later, but Firefox held out for a while.

    I'm normally not a fan of Chrome unilaterally adding something to the platform, but this has been a long time coming.

  • by gertrunde on 10/25/2024, 2:15:23 PM

    In all honesty, I've hated this feature with a passion ever since it appeared.

    If it was simply a matter of being used in the way outlined in the article, when someone creates a a link that references a particular piece of text, then fine, someone has deliberated intended the link to behave like that.

    And then we have the lovely folk at Google search... who think it's fun to drag my attention off to a random part of a page that isn't where I want to be, forcing me to right-click, remove annotation and scroll back up to the top of the page.

    That doesn't seem like a massive hardship, but it gets quite frustrating when multiplied over the many searches done in a day/week/month.

  • by rakoo on 10/25/2024, 2:02:20 PM

    Unsurprisingly this is something you could do in Plan 9:

        /path/to/file:/from.*to
    
    opens the file and sets the selection to the range of text between "from" and "to". Bonus: you can use regular expressions.

    It pains me to see the web having strayed so far from its focus on interlinking. It's easy to make a parallel when on one side device makers have taken control back by removing access to files and putting applications first (this is the only model on mobile), to the point that those makers have enormous control over apps' existence, and the web where applications are now the only way to access content, to the point that content may or may not available if the right API exists.

  • by shakna on 10/25/2024, 1:03:52 PM

    Super unintuitive that the HTTP header a site can set, to disable this, is:

        Document-Policy: force-load-at-top

  • by fbn79 on 10/25/2024, 11:48:27 AM

    In Google Chrome select text, right click and click "copy link to highlight". It create a link with ~:text=

  • by thinkingemote on 10/25/2024, 1:21:17 PM

    Programmatically what can a developer do with this?

    I see that there is a method and an object to see if its enabled or not. And there is a way to get the whole fragment which can be parsed.

    Are there methods to see whether some text in the fragment was actually highlighted or not? Are there methods to programmatically select text?

    Could there be a way to, for example, draw a rectangle around the highlighted section, to get the coordinates of the text, to read out the selected text, to store what words people select and link to etc

    Maybe it's an external link about headline news and the news title got changed by the editor. Maybe the developer may want to change the selection to the edited title so the user isn't surprised. Maybe its a multi lingual blog post and the user links using another language... etc etc

  • by pbiggar on 10/25/2024, 11:54:25 AM

    I use these for footnotes, eg in [1] which had a lot of footnotes. Ghost and other blogs don't support footnoting well afaict. Sometimes I miss restructured text, which did this quite well, markdown alas does not.

    [1] https://blog.paulbiggar.com/i-cant-sleep/

  • by donohoe on 10/25/2024, 2:10:33 PM

    I built something like this for The New York Times and it was one of the more fun projects I did there.

    The thing I really hoped this "new" version would account for is when text changes and having links survive minor edits/changes. Perhaps I missed it and it does.

    - https://github.com/NYTimes/Emphasis

    - https://open.nytimes.com/emphasis-update-and-source-6ffac5e6... (2011)

  • by jiri on 10/25/2024, 11:46:24 AM

    It would be nice to have similar feature like this, but to highlight rectangle (instead of text) on the page to focus viewer on some specific area. I send screenshots with highlight quite often.

  • by al_borland on 10/25/2024, 11:05:58 AM

    Every time I run across this I think about how useful it is, then forget it exists and never actually use it.

  • by ninalanyon on 10/25/2024, 5:11:50 PM

    Looks like Firefox is lagging behind. It understands the url but there doesn't seem to be a way to create it from the UI. Chromium has "Copy link to highlight" in the right click/context menu but Firefox 131.0.3 doesn't. There is an add-on though: https://addons.mozilla.org/en-US/firefox/addon/link-to-text-...

  • by andai on 10/25/2024, 11:49:57 AM

    I've noticed that Google inserts this into result links sometimes, taking you to the relevant part of the page.

  • by srcnkcl on 10/25/2024, 10:36:38 AM

    I always wished something to point at typos in websites... thanks for that

  • by westurner on 10/25/2024, 10:48:27 AM

    Is there a specified / supported way to include other parameters in the URI fragment if the fragment part of the URI starts with :~:text=?

      https://example.com/page.html#:~:text=[prefix-,]textStart[,textEnd][,-suffix]
      https://example.com/page.html#:~:text=...
      https://example.com/page.html#:~:text=...&param2=two&:~:param3=three
    
    w3c/web-annotation#442: "Selector JSON to IRI/URI Mapping: supporting compound fragments so that SPAs work" (2019): https://github.com/w3c/web-annotation/issues/442

    WICG/scroll-to-text-fragment#4: "Integration with W3C Web Annotations" (2019): https://github.com/WICG/scroll-to-text-fragment/issues/4#iss...

  • by rkta on 10/25/2024, 11:17:45 AM

    > Text fragments are currently supported in all the browsers.

    All meaning all the browsers listed in the linked table. These may be the major browsers, but not all of them.

  • by amadeuspagel on 10/25/2024, 12:49:37 PM

    I wonder whether it was a mistake to separate this feature from a standard selection.

    I don't know how to design it separately. The default is that selections are blue and fragments are purple, but if you choose different colors for both, in line with your color scheme, how will people know which is which? I guess you can still choose different tones of blue and purple.

    Why shouldn't selecting text automatically update the address?

  • by dbodin11 on 10/25/2024, 2:47:46 PM

    This is the ultimate time saver feature when sharing. I built a web layer that does this, but goes further with multiple highlights, navigation, and rich inline communication with humans and AI, which is integrated with a web app to save, organize, and share with humans and AI. It’s https://www.kontxt.io

  • by dveeden2 on 10/25/2024, 11:19:16 AM

    With a addon this is much more usable, not sure why there isn't a selection-to-text-fragment-link functionality builtin to Firefox...(same for other browsers?)

    https://addons.mozilla.org/firefox/addon/text-fragment/

  • by hk1337 on 10/25/2024, 12:35:48 PM

    It’s really cool but it seems rather convoluted for the typical user. We should perhaps start making good use of the ID attribute and linking to that first before we start trying to use ~:text=

  • by seinecle on 10/25/2024, 1:51:35 PM

    I wonder how that can be leveraged for SEO

  • by polotics on 10/25/2024, 10:10:17 AM

    Very nice! Hopefully Firefox developers have the bandwidth to implement this as well, and not let Google Chrome have this feature as an "embrace and extend" differentiator. As for MS-Edge, well I guess it must be funny for Microsoft to see they're getting a taste of their own sweet old medicine...

  • by kwantaz on 10/25/2024, 2:36:31 PM

    Copy link to highlight is best feature.

  • by _giorgio_ on 10/25/2024, 11:57:50 AM

    Can you disable it in firefox?

    shift+i -> "permissions" -> disable "override keyboard shortcuts"

  • by dakiol on 10/25/2024, 11:33:31 AM

    Is it just me or whenever I open a link with a text fragment, the page is loaded just fine but it takes one or two seconds to actually scroll down to the highlighted text?

    Usually in Chrome and when visiting sites that are not 100% pure text (e.g., bloated Confluence docs)

  • by RedShift1 on 10/25/2024, 10:08:39 AM

    Sidenote: please don't hijack CTRL+F on webpages, thanks. Sincerely, the world.

  • by xp84 on 10/25/2024, 1:43:42 PM

    This also works perfectly in Microsoft Edge and has for a long time. Pointing this out because the post makes several references to things being exclusive to Chrome, when really it's probably just Chromium.

    (I'm still puzzled why so many more people choose to use a browser distributed by the world's largest ad network over one with all the same features plus a few nice add-ons, made by a software company.)