我已经在我的注册页面中实现了Google Invisible Recaptcha。在Firefox和IE中似乎可以正常工作,但在Google Chrome中却无法正常工作(有时会出现验证码窗口,有时却没有)。
根据Google文档实施
链接-https://developers.google.com/recaptcha/docs/invisible
<html>
<head>
<script>
function onSubmit(token) {
alert('thanks ' + document.getElementById('field').value);
}
function validate(event) {
event.preventDefault();
if (!document.getElementById('field').value) {
alert("You must add text to the required field");
} else {
grecaptcha.execute();
}
}
function onload() {
var element = document.getElementById('submit');
element.onclick = validate;
}
</script>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</head>
<body>
<form>
Name: (required) <input id="field" name="field">
<div id='recaptcha' class="g-recaptcha"
data-sitekey="your_site_key"
data-callback="onSubmit"
data-size="invisible"></div>
<button id='submit'>submit</button>
</form>
<script>onload();</script>
</body>
</html>
奇妙的Google chrome不支持google产品!!!!