On Thu, Apr 29, 2010 at 7:43 AM, cc <[email protected]> wrote: > Usually, just using the JavaScript `return` statement will be good enough -- > most versions of Greasemonkey wrap the script in an anonymous function for > this very reason. > > I'm assuming you mean "exit the current run of the current script" rather > than "disable the script until the user next enables it"? Because if it's > the latter, there isn't any good way to do that yet. > > On 2010-04-28 21:46, robro wrote: >> >> I have a script I wrote that watches for an event to occur on a >> webpage then notifies a user with a dialog box. When that occurs, I >> want the script to stop executing. How can I turn it off at that >> point? Thanks!
Maybe you have to formulate more precisely what 'stop executing' means. If by this you mean not triggering the notification the next time the event takes place, say you attached the mouseover event listener in this way: someObject.addEventListener(mouseover, myListener, false) Then, within 'myListener' you have to do: someObject.removeEventListener(mouseover, myListener, false) The parameters of removeEventListener must be the same as those of addEventListener. This causes the event listener to be removed by itself the first (and thus the only) time it is invoked. -- 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.
