On Tue, Apr 13, 2010 at 3:44 PM, Anthony Lieuallen <[email protected]> wrote:
>
> On 04/13/10 08:18, ppgl wrote:
>>
>> In my case, a Greasemonkey script modifies the rendered page by
>> inserting an img element to the page. This image has an onmousemove
>> attribute. ..
>>
>> Probably I am stuck because of the GM sandbox being separated form the
>> page DOM? What are my alternatives then?
>
> Pitfall #2.  Use event listeners, not "on___" properties.
>
> http://wiki.greasespot.net/Avoid_Common_Pitfalls_in_Greasemonkey

Just to be precise: you don't need to include a <script> tag. Just
define an event handler function for the mousemove event or similar
[1] and attach this handler to a target node via  <your
node>.addEventListener('mousemove', myHanlder, false).  When the event
is triggered, myHandler is called even if it was defined in the
Greasemonkey script instead of in the page.

[1] http://www.quirksmode.org/js/events_mouse.html

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to