我尝试从一次提交创建两个操作,但看起来我的表单提交无效。似乎function2()在function1()能够完成之前接管:
double.php
<DOCTYPE html>
<html>
<head></head>
<body>
<script>
alert('here we go');
</script>
</body>
<html>
double1.php
<DOCTYPE html>
<html>
<head>
<script>
function function1(){
document.getElementById("1").innerHTML = "1 changed!";
document.getElementById("theForm").action ='http://example.com/testbed/public/double.php';
document.getElementById('theForm').submit();
}
function function2(){
document.getElementById("2").innerHTML = "2 changed!";
window.location.replace("https://stackoverflow.com");
}
</script>
</head>
<body>
<form method="post" action="" id="theForm">
<input type="button" onclick="function1();function2();" />
</form>
<div id='1'></div>
<div id='2'><div>
</body>
<html>