Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you use <code>attachEvent</code> for IE you cannot guarantee the order in which events are fired. See <a href="http://msdn.microsoft.com/en-us/library/ms536343(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms536343(VS.85).aspx</a> </p> <blockquote> <p>If you attach multiple functions to the same event on the same object, the functions are called in random order, immediately after the object's event handler is called.</p> </blockquote> <p>(I actually have seen that events are called in reverse order, not random). Anyway, libraries generally tend to use <code>attachEvent</code> deep down, so you're stuck with the same problem.</p> <p>Having said that, if you can inspect a node for it's 'click' handlers (eg you have an "onclick" attribute setup on your node in your markup), then you <em>can</em> put "yours" ahead of "theirs":</p> <pre><code>var nodes = document.getElementsByTagName('*'); // collect your nodes however for(var i=0; i &lt; nodes.length; i++) { var node = nodes[i]; if(!node.onclick) continue; // At this point we have a node with an "onclick" attr. // Hijack onclick to do something else first. var original = node.onclick; node.onclick = function() { doSomethingElse(); return original.apply(this, arguments); } } </code></pre> <p>See <a href="https://stackoverflow.com/questions/446892/how-to-find-event-listeners-on-a-dom-node#447106">this answer</a> for how to inspect the a node's events in other libraries (if you are using one). You may be able to use it to <code>doSomethingElse()</code> with those libraries too. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload