You need:
this.link.onclick = this.EventMethod.bind(this);
…’bind’ is part of Prototype, and returns a function which calls your method with ‘this’ set correctly.
More Related Contents:
- ‘this’ does not work properly in another event. I’m clueless as to why [duplicate]
- How does the “this” keyword work?
- How to trigger event in JavaScript?
- What does “this” refer to in arrow functions in ES6?
- JavaScript: remove event listener
- Why is JavaScript bind() necessary?
- Javascript “this” pointer within nested function
- What is the difference between the mouseover and mouseenter events?
- VueJS: why is “this” undefined?
- Remove All Event Listeners of Specific Type
- adding ‘click’ event listeners in loop [duplicate]
- HTML “overlay” which allows clicks to fall through to elements behind it [duplicate]
- How do you log all events fired by an element in jQuery?
- JavaScript Callback Scope [duplicate]
- Add onclick event to newly added element in JavaScript
- The invocation context (this) of the forEach function call
- Does using $this instead of $(this) provide a performance enhancement?
- Attach an event in a child iframe to a handler in the parent window
- Can the unload Event be Used to Reliably fire ajax Request?
- Are event handlers in JavaScript called in order?
- jQuery prevent change for select
- adding event listener cross browser [closed]
- Detect double tap on ipad or iphone screen using javascript
- Monitor all JavaScript events in the browser console
- How can I stop an onclick event from firing for parent element when child is clicked?
- Listen for changes with localStorage on the same window
- Set variable in parent window from iframe
- Angular2 – catch/subscribe to (click) event in dynamically added HTML
- Add multiple window.onload events
- Replacement for deprecated `keypress` DOM event