Interesting documentation feature: updating URL field

Tony Atkins tony at raisingthefloor.org
Thu Jul 10 13:08:04 EDT 2014


Hi, All:

I too was curious and had ten minutes before a meeting... ;)

I read a good stack overflow post
<http://stackoverflow.com/questions/6146560/is-it-possible-to-have-the-url-change-while-you-scroll-down-a-single-page>,
Mozilla's dev docs
<https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history>,
and the original source.  I couldn't find a library they use (side note,
they use about ten analytics and tracking stacks, it's crazy).

I did find what looks like the way this is done, namely by using
window.history.pushState().  Check the dev docs link for the full syntax,
but to see it in action, just fire up the javascript console while viewing
a page that doesn't have any hash content, and issue a command like:

window.history.pushState({},"","#foo");
>

You'll immediately see the URL update without reloading the browser window,
and the update survives moving back and forward.

I'd imagine you'd just wire that in to something that monitors the scroll
activity to get the same effect they have.

Cheers,



Tony


On Thu, Jul 3, 2014 at 9:12 AM, Jonathan Hung <jhung at ocadu.ca> wrote:

> Hi Simon and Anastasia.
>
> I came across this site in doing EPUB 3 research.
> http://chimera.labs.oreilly.com/books/1234000000770/ch03.html
>
> If you visit the site and scroll up or down the page, the browser's
> address field will update according to the anchors within the document.
>
> I have to say that this functionality is very handy for bookmarking or
> sharing links. It also saves having to hunt down a link or a permalink to
> bookmark a specific location on a page.
>
> I don't know exactly how this is done - I assume it's some form of arcane
> magic, or at least some Javascript.
>
> Do you think something like this would be useful for Infusion
> documentation? I don't know how much of the content will benefit from this
> functionality.
>
> - Jon.
>
> --
>
> *JONATHAN HUNG*
>
> INCLUSIVE DESIGNER, IDRC
>
>
>
> *T:* 416 977 6000 x3951
>
> *F:* 416 977 9844
>
> *E:* jhung at ocadu.ca
>
>
>
> *OCAD UNIVERSITY*
>
> Inclusive Design Research Centre
>
> 205 Richmond Street W, Toronto, ON, M5V 1V3
>
>
>
> www.ocadu.ca
>
> www.idrc.ocad.ca
>
> _______________________________________________________
> fluid-work mailing list - fluid-work at fluidproject.org
> To unsubscribe, change settings or access archives,
> see http://lists.idrc.ocad.ca/mailman/listinfo/fluid-work
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idrc.ocad.ca/pipermail/fluid-work/attachments/20140710/f057becf/attachment.html>


More information about the fluid-work mailing list