Re: <script> as handler for XML events

Jonas Sicking <[email protected]> Mon, 10 Jul 2006 17:37:32 -0700
Newsgroups gmane.comp.mozilla.devel.xml
Message-ID <[email protected]>
Hi Chris,

Sorry for taking so long to get back to you. I had a big backlog of NG 
postings to read.

The problem with reusing <script> is that the semantics of <script> and 
what you want is slightly different. For example if you have something like:

   <script id="proxy" type="text/javascript"
            ev:event="click" ev:observer="para">
   alert("hello");
   </script>

You'll not only see an alert every time "para" is clicked, but also 
during loading of the document. To work around this ugly hacks like the 
one in mccobbs mail.

So I suggest that we add a new element, <handler> that can be used as 
EventHandler. This would solve the problem of handlers executing during 
load.

Additionally, we could require such elements to implement the 
EventListener interface which means that they can be used as 
event-handlers even when using the addEventListener function.

/ Jonas

Chris Cross wrote:
> Jonas,
> 
> I'm developing a Mozilla extension implementing XHTML+Voice, or X+V (see 
> http://www.w3.org/TR/xhtml+voice/ and 
> http://www.voicexml.org/specs/multimodal/x+v/12/) The X+V profile pulls 
> in VoiceXML <form> and makes it a handler for XML events. However, to 
> make a multimodal application truly interesting, the document author 
> needs the ability to respond to the XML events emitted by VoiceXML. 
> Opera and NetFront have implemented <script> as a handler by allowing it 
> to be specified in the XML events <listener> element, without otherwise 
> affecting the behavior of <script> (it still executes on page load, for 
> example.) This approach is used in examples in the XML spec but is not 
> normative. There was some discussion of including it in the Mozilla XML 
> events implementation 
> (https://bugzilla.mozilla.org/show_bug.cgi?id=164482) .
> 
> What are the options to implement this behavior in Mozilla?
> 
> chris