javascript code after form submission
I tested the following javascript code on a webpage.
<form method=POST id="someform" action="http://localhost/somepage.php" >
<input type=hidden name=stuff value="value">
</form>
<script>
document.forms['someform'].submit();
window.location="http://google.com";
</script>
The window successfully redire开发者_C百科cts to google after the form is submitted. I don't understand why. Isn't the control transfered to somepage.php? why is the window.location ... still executed.
Everything that is called is executed while the page doesn't disappear. The submit()
call doesn't block the execution, it returns immediately.
精彩评论