J'ajoute Google Recaptcha v2 problématiquement à une vue épine dorsale comme ceci:Retrait Recaptcha v2 problématiquement après avoir été résolu
// this is the callback function
var getRecaptchaResponse = function (response) {
if (response) {
thisView.captchaResponse = response;
thisView.canShowContinue();
} else {
alert("Captcha response was incorrect");
}
};
// render the recaptcha
var renderCaptcha = function() {
thisView.captchaWidgetId = grecaptcha.render('recaptcha-container', {
sitekey: GlobalSettings.recaptchaKey,
callback: getRecaptchaResponse,
size: 'compact'
});
};
// map the internal function to the window
// so that the callback registered in the
// link below can be called by JSONP.
window.renderCaptcha = renderCaptcha;
// load the script
$.getScript('https://www.google.com/recaptcha/api.js?onload=renderCaptcha&render=explicit', function() { });
Une fois que le Captcha est résolu avec succès, je veux le supprimer de l'interface utilisateur, donc je « m enlever simplement le conteneur div
:
// if the user has solved the captcha yet, don't continue
if (!thisView.captchaResponse) {
return;
}
// remove recpatcha
$('#recaptcha-container').remove();
Il ne semble pas être un API method que Google a offert de détruire le widget grecaptcha
correctement cependant. Est-ce un problème? Quelle est la manière recommandée de faire cela?
La suppression ci-dessus du conteneur fonctionne dans Chrome, mais pas dans IE11. Dans IE11, le défi captcha reste visible.
Vouliez-vous dire par programme? – Ezenhis
@Ezenhis exactement. Je cherche à faire 'grecaptcha.remove ('recaptcha-container'), ou quelque chose de similaire. – Junto