如何使用 reCAPTCHA v3 设置徽章位置? [英] How do you set the badge position with reCAPTCHA v3?
问题描述
我想在 v3 中使用内嵌徽章,但没有关于 v3 的徽章位置的文档.
I would like to use an inline badge with v3, but there is no documentation on badge position for v3.
推荐答案
您可以仅使用 Javascript 在 V3 中内嵌徽章,只是尚未记录.
You can make the badge inline in V3 with just Javascript it's just not documented yet.
将您的 render
参数设置为 explicit
并为回调添加一个 onload
参数,例如 onRecaptchaLoadCallback
.
Set your render
parameter to explicit
and add a onload
parameter for the callback, onRecaptchaLoadCallback
for example.
<script src="https://www.google.com/recaptcha/api.js?render=explicit&onload=onRecaptchaLoadCallback"></script>
然后像这样设置你的回调,不要忘记输入你想要你的徽章去哪里的 id/DOM 节点,在这种情况下,id 是 inline-badge
.
Then set up your callback like so and don't forget to enter the id/DOM node of where you want your badge to go, in this case, the id is inline-badge
.
<script>
function onRecaptchaLoadCallback() {
var clientId = grecaptcha.render('inline-badge', {
'sitekey': '6Ldqyn4UAAAAAN37vF4e1vsebmNYIA9UVXZ_RfSp',
'badge': 'inline',
'size': 'invisible'
});
grecaptcha.ready(function() {
grecaptcha.execute(clientId, {
action: 'action_name'
})
.then(function(token) {
// Verify the token on the server.
});
});
}
</script>
注意:'badge'
的有效值为 'inline'
、'bottomleft'
、'bottomright'
和 >'底部'
.'bottom'
和 'bottomright'
是同义词.
Note:
Valid values for 'badge'
are 'inline'
, 'bottomleft'
, 'bottomright'
, and 'bottom'
.
'bottom'
and 'bottomright'
are synonyms.
这篇关于如何使用 reCAPTCHA v3 设置徽章位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!