Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First: there's a problem with your HTML. You're using the short syntax for the <code>A</code> -- meaning that the text isn't actually part of the <code>A</code> content. Many browsers don't like the short syntax for <code>A</code> tags anyway -- not your fault, but it's our job to be more tolerant than browsers are.</p> <p>Here's the corrected version:</p> <pre><code>&lt;a tabindex="7" style="cursor: pointer;" class="button" id="saveTocAddNew" onClick="saveTdsAddNew();"&gt;&lt;span&gt;Save &amp; Add Another&lt;/span&gt;&lt;/a&gt; </code></pre> <p>Depending on the browser and DOCTYPE, it is significant whether the event name is all lowercase or not. Just something to look for.</p> <p>Finally, by default your onclick event will only fire for clicks and Enter -- not for spacebar. Many browsers treat the spacebar as a pagedown thing. If you are sure you want to capture spacebar events on this <code>A</code> and treat them like Enter, you'll need to define a keypress event that looks for spacebars. Like so:</p> <pre><code>function addNewKeys(event) { if(!event) var event = window.event; // cross-browser shenanigans if(event.keyCode === 32) { // this is the spacebar saveTdsAddNew(event); } return true; // treat all other keys normally; } </code></pre> <p>(Remember to bind this new function to the onkeypress of that <code>A</code>.)</p> <p>Note that I'm passing the <code>event</code> to the <code>saveTdsAddNew</code> function. That's because I think event handlers normally receive the <code>event</code> object as their argument, so this preserves the existing pattern. From the <code>event</code>, you can retrieve the element that was clicked/keyed-on, etc.</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