Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, let's fix it for you.</p> <p>First take a look in this fiddle that I've made for you: <a href="http://jsfiddle.net/gartz/7dASQ/3/" rel="nofollow">http://jsfiddle.net/gartz/7dASQ/3/</a></p> <p>Let's explain:</p> <ol> <li>if you use the method <code>submit()</code> it baypass the <code>onsubmit</code></li> <li>you can simulate the <code>click</code> event for the element button, that way will submit your form without bypassing onsubmit</li> <li>Your audio element was with type wrong, the time is file tipe, not hidden, you can hide it using CSS <code>style="display: none"</code> or remove the <code>controls</code> tag</li> </ol> <p>This is your fixed code:</p> <pre><code>&lt;script type="text/javascript"&gt; function submitHidden( ){ var evt = document.createEvent("MouseEvents"); evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); document.getElementById("submitButton").dispatchEvent(evt); } window.onload = function() { setInterval(submitHidden, 10*1000 ); } function audioPlay(){ document.getElementById("sirine").play(); return false; } &lt;/script&gt; &lt;form id="formParser" action="#" method="post" onsubmit="audioPlay(); return false;"&gt; &lt;input id="submitButton" type="submit" value="Click here to send"&gt; &lt;/form&gt; &lt;audio id="sirine"&gt; &lt;source src="http://musicsringtone.com/wp-content/uploads/2009/01/air-raid-siren-alert.mp3" type="audio/mpeg"&gt; &lt;/audio&gt; </code></pre> <p>PS.: I do not take responsibility if someone try to kill you because a sirene playing every 10 secconds.</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