<script>
window.onload = login;
function login(){
document.getElementById("username").value = '<?php echo $_COOKIE["username"]; ?>';
document.getElementById("password").value = '<?php echo $_COOKIE["password"]; ?>';
document.getElementById("loginForm").submit();
}
</script>
<form id="loginForm" action="index.php?user-login" method="post" >
<input id="username" type="text" />
<input id="password" type="password" />
<input name="submit" type="submit" value="登录"/>
</form>
=======================================
JS 方法中的 submit() 不执行 页面没有跳转。
在群里 网友 帮我解答了。 很感谢。
<input name="submit" ,按钮的名字不要取成关键字
你调用submit()的时候,JS不会执行,因为有的名字叫submit
本文探讨了在JavaScript中使用submit()方法时遇到的问题:页面未按预期进行跳转。通过对代码的具体分析发现,input元素的name属性设置为submit会导致JS的submit()方法无法正常工作。文中提供了解决方案并提醒开发者避免将按钮名称设置为关键字。
8万+

被折叠的 条评论
为什么被折叠?



