Live data from Hacker News

Smarter Than 'Ctrl+F': Linking Directly to Web Page Content

alfy.blog

61–70 of 145 posts

Re: Smarter Than 'Ctrl+F': Linking Directly to Web Page Content

#61

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

Hijacking CTRL+K sucks, too! It's the shortcut used to focus the browser search input in Firefox, but the industry has seemingly decided it's a great way to launch a command palette.

I recently implemented this, and the users loved it, though I was disappointed to hear it may have frustrated a usually silent group.

I'm open to feedback! What would be a better approach? Please don’t just suggest “no custom shortcuts for any web app”—people spend 60-70% of their workday using the UI components my team maintains. While random sites hijacking shortcuts is definitely frustrating, in our case, the pros seem to outweigh the cons.

Maybe allowing users to disable or customize shortcuts could be a solution? Or would that be over-engineering?

Honestly, I think the web platform could use a standard API for defining shortcuts, with browsers providing a UI to manage or disable them. Maybe I'm still over-engineering here.

Would really appreciate hearing others’ thoughts!

Re: Smarter Than 'Ctrl+F': Linking Directly to Web Page Content

#62
post #36

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.

Pretty difficult to specify a rectangular region within reflowable content. It would need to be anchored by element edges, but if the algorithm chooses bad anchor elements or they reflow in weird ways (a layout that goes from horizontal to vertical on small screens, for instance), everything breaks.

Re: Smarter Than 'Ctrl+F': Linking Directly to Web Page Content

#63
post #23

> 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 market share, that table contains all the major browsers and more.

Re: Smarter Than 'Ctrl+F': Linking Directly to Web Page Content

#65

Earlier quoted context omitted.

Hijacking CTRL+K sucks, too! It's the shortcut used to focus the browser search input in Firefox, but the industry has seemingly decided it's a great way to launch a command palette.

I recently implemented this, and the users loved it, though I was disappointed to hear it may have frustrated a usually silent group. I'm open to feedback! What would be a better approach? Please don’t just suggest “no custom shortcuts for any web app”—people spend 60-70% of their workday using the UI components my team maintains. While random sites hijacking shortcuts is definitely frustrating, in our case, the pros…

> I was disappointed to hear it may have frustrated a usually silent group.

This group isn't usually silent (far from it), they're just not usually your users.

If you're building a web app a la Notion, Figma, Google Docs, Slack, or anything similar: just ignore the "the web should just be documents that strictly use the platform" complaints. Ensure you build in the required accessibility hooks (since those don't come natively to most custom work), but your users will thank you for accommodating their specific needs better than the platform does.

If you're building a web page that mostly presents information... yeah, maybe listen to the people here.

The main thing you're seeing here is that there's a subset of developers who haven't ever really liked the idea that the web became the primary means of deploying applications.

Re: Smarter Than 'Ctrl+F': Linking Directly to Web Page Content

#66

Earlier quoted context omitted.

Please don't hijack HN threads with unrelated gripes about the modern the web and please don't pretend to speak for the world.

Unrelated? CTRL+F is literally in the title...

It is. But the article doesn't talk about hijacking its behaviour.

Re: Smarter Than 'Ctrl+F': Linking Directly to Web Page Content

#68
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

Re: Smarter Than 'Ctrl+F': Linking Directly to Web Page Content

#69

Earlier quoted context omitted.

Please don't hijack HN threads with unrelated gripes about the modern the web and please don't pretend to speak for the world.

Unrelated? CTRL+F is literally in the title...

And only in the title. It doesn't mention the keyboard shortcut once in the body because it's not about keyboard shortcuts, it's about "linking directly to web page content".

In addition to unrelated gripes, it's generally considered bad practice to comment only based on the title.

Re: Smarter Than 'Ctrl+F': Linking Directly to Web Page Content

#70
post #60

Super unintuitive that the HTTP header a site can set, to disable this, is: Document-Policy: force-load-at-top

Unfortunately, not supported away from chromium derived browsers ATM: https://caniuse.com/document-policy (though given current market shares that sill means the majority of your user base is likely to have support)
Post reply on HN