News for hackers. Stuff that matters.

Ask HN: How would you link to specific parts of a page?

Hi all,

The other day, a friend and I were eating lunch and I was dropping my usual, subliminal "so, any cool neat ideas for websites?" type questions. He always seems to have complaints about the web, which are good for somebody like me (always looking for fun projects). After some discussion we started coming up with a pretty neat sounding idea.

The idea is to be able to highlight some text on a page, and create a permalink to the page that shows those highlights. For example, you're on Wikipedia and see a sweet quote, or really important word, and you want your buddy to read it. You could copy and paste it to him, over AIM or something, and then send him the URL, too. Or you could just send him the URL and say "scroll down to the third paragraph." Or, you could use this idea and highlight that quote or word somehow and create a permalink to that exact word. It would function exactly like HTML anchors do, but without requiring that page to have an anchor where you want to link to.

I don't know if anything likes this exists in a pure Javascript form or not. I know there are browser plugins that can kind of do this. I know some blogs append anchors to every paragraph for this. But, that doesn't really matter, I'm just trying to figure out how this would be possible without using those methods.

I was thinking in terms of Javascript, but I'm not sure if it's quite possible. I'm pretty sure you can't load up the page being linked to in an iframe and run javascript on it. I know you can't ask that page to load your JS.

Does anyone have any ideas on how this could be possible without a browser plugin?

Edit: I have also thought about a bookmarklet. This would allow you to generate a link to a certain area of a page, using whatever algorithms you had to find that area and create a link. But, I don't know how it would work in the opposite direction: going from link -> area of page.

( 9 comments | 8 points | on HN )
Re:Ask HN: How would you link to specific parts of a page? by bigiain on Thursday December 02, 2010 @10:48PM (#1964662)
You could proxy the page, and rewrite bits of it on the fly (adding a class and/or anchors around the bit you wanted to highlight).

If I wanted to do this, I'd start by hacking for a few hours on http://www.jmarshall.com/tools/cgiproxy/ I'm pretty sure I could get a (non-scalable, resource hungry) proof of concept running in a evening starting from there - that'd be enough to start showing people and seeing if they even understand why you might want to use something like this...

Re:Ask HN: How would you link to specific parts of a page? by sorghum on Thursday December 02, 2010 @11:55PM (#1964805)
I worked on just this for last year's Rails Rumble:

http://morsurl.com/

The site acts as a proxy, injecting some Javascript based on SelectorGadget to allow the user to select parts of the page, and injecting inline styles to display the highlighted parts of the page.

Re:Ask HN: How would you link to specific parts of a page? by Skywing on Friday December 03, 2010 @12:06AM (#1964833)
Nice, man. Cool name for it, too.
Re:Ask HN: How would you link to specific parts of a page? by uvince on Thursday December 02, 2010 @11:37PM (#1964765)
Done. No extension necessary.

http://awurl.com/wcD8whqQG

Re:Ask HN: How would you link to specific parts of a page? by briandoll on Thursday December 02, 2010 @11:39PM (#1964771)
Clickable link to the actual service: http://www.awesomehighlighter.com/
Re:Ask HN: How would you link to specific parts of a page? by Skywing on Thursday December 02, 2010 @11:43PM (#1964783)
Ah, nice. Looks like they proxy it.
Re:Ask HN: How would you link to specific parts of a page? by smoody on Friday December 03, 2010 @01:03AM (#1964937)
also look at www.snip.ly -- it doesn't highlight per-se, but it brings the text you've selected in a lightbox over the original article. Like awesomehighlighter (which someone else mentioned, it won't work on NYTimes pages.

also, check out Diigo. It's the bookmarking service i use. They let you highlight text, add post-its, etc. as part of the bookmarking process.

Re:Ask HN: How would you link to specific parts of a page? by cwtann on Thursday December 02, 2010 @11:14PM (#1964710)
This concept sounds like a great idea for a chrome extension.
Re:Ask HN: How would you link to specific parts of a page? by Skywing on Thursday December 02, 2010 @11:32PM (#1964753)
Well, you could probably write an extension pretty easily, but that doesn't quite make the links very portable.