[Ur] onload attribute

austin seipp as at hacks.yi.org
Tue Sep 20 14:01:51 EDT 2011


On Tue, Sep 20, 2011 at 12:16 PM, Gergely Buday <gbuday at gmail.com> wrote:
> Hi,
>
> the manual says:
>
> Links, forms, and most client-side event handlers are not followed during
> this syntactic traversal, but <body onload={...}> handlers are
> examined, since they run right away and
> could just as well be considered parts of main page handlers.
>
> This is the only place where the onload attribute is discussed. Is it
> right that only the <body> tag can have this attribute?

A quick skim through the basis library shows that the 'img' tag also
specifies an 'onload' attribute. A good thing to keep in mind is since
most of the syntactic sugar for XML/SQL queries in the compiler
dissolves in a pretty straightforward manner to values in basis.urs,
you can look up the HTML tag in the basis library and see what sort of
attributes it can have. The attribute name for a tag (for example,
'onload') merely dissolves to the Name of a type level record, which
is a type-level parameter to the function in question - so 'img' takes
a {Type} where one of the fields is 'Onload = transaction unit'. You
can see that here:

http://hg.impredicative.com/urweb/file/7ad5227a3ed9/lib/ur/basis.urs

> So, all of the client threads should be started on page loading?

'spawn' is merely a function of type transaction unit -> transaction
unit. It could be called by any client-side handler or function based
on some event - clicking a button may spawn a timer thread that counts
down, for example. 'onload' events special and are just followed
explicitly since they run without question on every page load - and
thus needs to be checked for side-effects, since an onload handler
could just do an 'rpc' call back to the server to do some SQL table
modifications.

> - Gergely
>
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
>



-- 
Regards,
Austin



More information about the Ur mailing list