Re: window.event and Event.srcElement

Le 25/03/2013 15:29, Boris Zbarsky a écrit :
> On 3/25/13 10:17 AM, Dave Methvin wrote:
>> What content depends on them
>
> Most typically, content that does this sort of thing:
>
>   <script>
>     function something() {
>       alert(event.target);
>     }
>   </script>
>   <div onclick="something()">Click me</div>
>
> but also content that does this:
>
>   <svg><rect onclick="alert(event.target);"></rect></svg>
For the latter case, a scoping trick might work. In essence, on* code 
could run within a scope "located" between the code scope and the global 
scope. This intermediate scope would only contain an "event" variable 
with the right object as value. That would avoid adding the global 
"event" variable while keeping code as described work.

For the former case, things cannot be as easy as naively inserting an 
intermediate scope, because the function definition is somewhere else, 
but maybe we can get away with an equivalent trick. Thoughts?

> A brief look at stackoverflow will show that this is something authors 
> run into a lot.  And that's just the ones that are bothering to test 
> in multiple browsers.
 From what you've seen is it the on* case?

> If you want specific site examples www.ocn.ne.jp (on "mobile" only, 
> natch, thanks to only testing in WebKit) is the most recent one I came 
> across.
Is it the on* case? (how do you test for "mobile only"?)

David

Received on Monday, 25 March 2013 18:47:31 UTC