W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2009

[whatwg] <a onlyreplace>

From: Rowan Nairn <rnairn@gmail.com>
Date: Sat, 31 Oct 2009 21:00:43 -0700
Message-ID: <989aa6910910312100v5e20d125y998162d5ca85bffe@mail.gmail.com>
> On Sun, Oct 18, 2009 at 4:30 AM, Ian Hickson <ian at hixie.ch> wrote:
> > My recomendation would be to follow the process for adding features:
> >
> > ? http://wiki.whatwg.org/wiki/FAQ#Is_there_a_process_for_adding_new_features_to_a_specification.3F
> >
> > In particular the bit about experimental implementations. I think this
> > idea looks very interesting, but it's hard to evaluate without concrete
> > experience with a browser implementing this (or, as Jonas suggests, a
> > library that hacks it in).
> >
> > It seems like the kind of thing that we could adopt early on in the next
> > feature cycle, if it turns out to be a good solid model.
>
> Yup, was planning on this. ?Just wanted to hack it out on the list
> first before jumping down any rabbit holes.
> If nobody beats me to it, this should be relatively easy to hack in
> (and may already be hacked in in some form, via mooTools?).
> ~TJ

Hi Tab,

I was just about to propose something similar so I was happy to find
the recent discussion of onlyreplace on the mailing list.  (Should
have gotten around to it before Last Call, doh!)

My use case is slightly different than yours.  You want to do AJAXy
replaces without javascript.  I want to provide an animated page
transition that doesn't break the back button or the URL bar and
degrades gracefully in non-javascript UAs.  You can see an example of
this at http://mrtaggy.com/ .  This is a site I launched last year
that uses animations to show transitions between search result pages.
Leaving aside whether you like this particular set of animations, I
think you'll probably a agree that animations are used well in many
applications to help users keep track of change.   It would be nice if
this was easy to do on the web.

I was going to propose a similar attribute on links and forms but I
hadn't envisioned the automatic scheme from replacing sections of
pages.  I think the automatic algorithm is great and necessary but I
also think it would be useful to let developers customize the
transition from one view to another.  One way to do this might be a
new event, onpagereplace or something, that fires when an onlyreplace
link is clicked.  If you don't preventDefault() then the automatic
algorithm for replacing sections would run.  If you do then you can
customize the transition yourself.

The way this is implemented in MrTaggy is with a hidden iframe.
Certain links target the iframe (btw, this suggests that onlyreplace
could instead be target=_replace) and an onload event on the iframe
triggers the code that animates the transition from the old view to
the new.  The page that loads in the iframe is a full results page so
without javascript (and no hidden iframe) every thing works fine.
Also the back button works on all browsers, old and new (try adding a
tag to an existing query and then clicking back).  The only problem is
that the URL bar does not update.  Ultimately I made the difficult
decision that back/forward was more important than bookmarking/link
sending/etc.  You can't have both in legacy browsers.

...which is where the (future) spec comes in.  I'd love to see this
made easier.  pushState is fine but it doesn't degrade gracefully like
this and it seems a bit too general even.  Part of the attraction of
onlyreplace+transitions is it forces developers to think about
progressive enhancement of pages that work fine without javascript.
Let me know if I can help with your formalization efforts.

Rowan
Received on Saturday, 31 October 2009 21:00:43 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:18 UTC