我已在我的注册页面中实施了Google Invisible Recaptcha . 它似乎在Firefox和IE中运行良好,但它在谷歌浏览器中工作不一致(有时会出现验证码窗口,有时它不会出现) .
基于谷歌文档实现
链接 - 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>
想知道谷歌Chrome不支持谷歌产品!!!!