所以我有一个表单,其中
问题是:
onsubmit="return reg_check(this)"
,而reg_check()
是头部中的javascript函数,应该检查表单数据,并且由于其中一个任务是检查用户名是否在需要php的数据库中,所以我想重定向到执行此任务的php页面。问题是:
window.location.href
不起作用!这是函数的简化版本,当然main.php
只是我得到的一个随机页面:function reg_check(myForm) {
alert("before redirect..");
window.location.href = "http://localhost/main.php?width=" + screen.width + "&height=" + screen.height;
alert("after redirect..");
}
“before redirect”和“after redirect”的提示框可以正常显示,只是页面没有跳转。同样地,如果我尝试在body中直接键入重定向的URL:
<script type="text/javascript">
alert("before redirect..");
window.location.href = "http://localhost/main.php?width=" + screen.width + "&height=" + screen.height;
alert("after redirect..");
</script>
它会重定向。
有什么办法可以让它起作用吗?