Re: about attachEvent() and detachEvent()



stanleyxu wrote:
I try to write a script to fix context-menu-hijack.
[...]
But when it is hijacked by "document.attachEvent('oncontextmenu',
hijack)", the previou fixes doesn't work any more.

Is it possible to detach all attached event handler from an event, even
when the name of those event handlers are unknown?

It is not event handlers that are attached, but event listeners. Event
handlers are intrinsic immutable parts of the DOM that execute attached
event listeners in specified order.

I am afraid it is not possible to detach an event listener from an object if
you don't have a reference to that. Determining a reference at runtime is
generally possible with source code parsing, however the reference can be
obfuscated by the offending script-kiddie just as easily.

Nevertheless, there are a number of other ways to work around context-menu
hijacking, with disabling script support being only one of them.


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
.



Relevant Pages

  • Re: Alternative Ways To Implement "Events"
    ... In some places .NET uses attributes to subscribe event handlers. ... "event" by providing an interface implementation. ... reference to objA). ... callback mechanisms that are available in .NET (even if they are independent ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Weakreference Multicast Delegates
    ... I would like to confirm my understanding of your issue. ... I understand that you would like the event handlers to ... There are a series of UI based controls that sit around ... no need to keep a reference. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Anonymous Methods scope question
    ... CheckBox cb = new CheckBox; ... Notice that I reference the local variable cb inside the anonymous event handler. ... Essentially I think that, when these anonymous event handlers are invoked, their copy of cb should always be a reference to the _last_ CheckBox created - because they have a reference, not a copy, of their containing scope. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Weird GC / Memory / XmlDocument.LoadXML memory problem
    ... there are a lot of event handlers - I don't know if any are connected to ... However, if I have a normal reference, and null it, ... XmlDocument, populated via LoadXML. ... If I keep this reference, the system looses more and more memory until ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Question on Component
    ... Load event handlers. ... I have successfullly hooked up to the parent Form's event. ... >> AFAIK you can't unless you create your own custom designer and serialize ... >> code that sets the form reference to a property of your component. ...
    (microsoft.public.dotnet.framework.windowsforms)

Loading