Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to ignore first event and skip to second?
    text
    copied!<p>I have a table-row that has a Javascript action attached to mouse clicks anywhere inside the table row:</p> <pre><code>&lt;tr onmousedown="someAction(this)"&gt; &lt;td&gt;cell 1&lt;/td&gt; &lt;td&gt;cell 2&lt;/td&gt; &lt;td&gt;&lt;a href="page2.html"&gt;cell 3&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>If a user clicks anywhere in the row, I want the Javascript action, someAction(this), to be followed. However, if a user clicks on the link to page2, then I want the action ignored and the link followed.</p> <p>Unfortunately, the action is being observed first, which happens to move the linked text's position just enough for the click to be dropped. In other words, the user cannot actually click on the link and go to page2, in this case.</p> <p>How can I disable the mousedown action for clicks over the link?</p> <p>Thanks!</p> <p><strong>Update:</strong> Based on the answers, I ultimately included the following JavaScript in the end of the HTML, which registered an event handler to stop propagation as suggested, like so:</p> <pre><code>... &lt;script type="text/javascript" language="javascript"&gt; //&lt;![CDATA[ function stopEvent(ev) { ev.stopPropagation(); } var links = document.getElementsByTagName('a'); for (var i = 0; i &lt; links.length; i++) { links[i].addEventListener("onmousedown", stopEvent, false); } //]]&gt; &lt;/html&gt; </code></pre> <p>This could have easily been included in the document's onload event, but the CDATA section was already required for other reasons, so I added what I needed here.</p> <p>Thanks for all the help and good suggestions! :)</p>
 

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