Reputation: 41
I'm looking for a way to know the last event fired by an external object ( HTML tag).
The problem is that when I put some code in the page to handle specific event through the HTML tag <script for="" event="">handler()</script>
, the event listener function(handler()) get also executed whenever the script tag is loaded into the page and not only when the specific event is fired.
The window.event variable is always null if checked during the event handler execution.
Test environment: IE10
Upvotes: 1
Views: 92
Reputation: 4183
You should register the event differently:
<script>document.getElmentById("SomeElement").addEventListener("click", handler);</script>
This will prevent your function handler()
from executing when the browser parses your script tag.
Upvotes: 1