HTML submit button sound issue
<p>I want to activate a sound when the user presses on my submit button. It seems that one must delay the operation of the button (otherwise the window is closed and there is no sound). With the default button I don't have this problem (i.e. when I delay the operation with setTimeout(), there is a sound and then a new window is opened) but not with submit button (is just moves to the defined window with the necessary parameters). How can I solve this?</p>

<p>HTML:</p>

<pre><code>&lt;input class="window_change_button" type="submit" value="Continue" onclick="moveOn()"&gt;
</code></pre>

<p>JavaScript:</p>

<pre><code>function moveOn(){
    buttonPressed();
}

function goBack(){
    buttonPressed("main.html"); 
}

function buttonPressed(nextWindowUrl){
    buttonPressedSound();
    setTimeout(function(){
        if (nextWindowUrl){
            window.location.href = nextWindowUrl;
        }
        }, 100);
}

function buttonPressedSound(){
    var audio = new Audio("sounds/button_press.wav");
    audio.play();
}
</code></pre>