我想在页面完成加载后使用 JS 添加代码自动自动提交表单我也需要它提交输入值提交并且验证码响应在我单击手动自动工作但没有提交输入“g-recaptcha-response”值时效果很好
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://www.google.com/recaptcha/api.js?render=<?php echo $captcha_site_key ?>"></script>
</head>
<form action="check.php" id="myform" method="POST">
<input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response">
<input type="Submit" name="Submit">
</form>
<script>
grecaptcha.ready(function() {
grecaptcha.execute('<?php echo $captcha_site_key ?>', {action:'validate_captcha'})
.then(function(token) {
document.getElementById('g-recaptcha-response').value = token;
});
});
</script>
<script type="text/javascript">
window.onload = function(){
document.getElementById("myform").submit();
}
</script>
</body>
</html>
忽然笑
慕村225694