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 redirects 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.
asked May 9, 2011 at 23:32
extraeee
3,2065 gold badges30 silver badges28 bronze badges
1 Answer 1
Everything that is called is executed while the page doesn't disappear. The submit() call doesn't block the execution, it returns immediately.
answered May 9, 2011 at 23:35
entonio
2,1932 gold badges19 silver badges28 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-js
window.locationpointing to.