开发者

javascript code after form submission

开发者 https://www.devze.com 2023-03-04 14:23 出处:网络
I tested the following javascript code on a webpage. <form method=POST id=\"someform\" action=\"http://localhost/somepage.php\" >

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消