2017-08-09 3 views
1

私はGoogleのreCAPTCHAのを追加しているV2という問題がそうのようなバックボーンビューへ:削除reCAPTCHAのV2という問題が解決された後

// 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() { }); 

キャプチャは、私はUIからそれを削除するに成功解くので、私れると単にdivコンテナ削除「M:

// if the user has solved the captcha yet, don't continue 
if (!thisView.captchaResponse) { 
    return; 
} 

// remove recpatcha 
$('#recaptcha-container').remove(); 

すると、Googleがが正しくgrecaptchaウィジェットを破壊するために提供してきましたAPI methodがあるように思えません。これは問題ですか?これをお勧めする方法は何ですか?

上記のコンテナの取り外しはChromeでは機能しますが、IE11では機能しません。 IE11では、キャプチャチャレンジは引き続き表示されます。 reCAPTCHAののよくある質問を1として

+0

を使用してキャプチャオブジェクトをリセットする必要がありますが、プログラムもしかしてようですか? @Ezenhisは正確に – Ezenhis

+0

です。私は 'grecaptcha.remove( 'recaptcha-container');や類似のものを探しています。 – Junto

答えて

1

、コンテナを削除した後、あなたはgrecaptcha.reset(id)

https://developers.google.com/recaptcha/docs/faq

I'm getting an uncaught SecurityError: blocked a frame with origin " https://www.google.com " from accessing a frame with origin "". What should I do?

This typically occurs if the reCAPTCHA widget HTML element is programmatically removed sometime after the end user clicks on the checkbox. We recommend using the grecaptcha.reset() javascript function to reset the reCAPTCHA widget.

+0

私は何のエラーも出ていませんでしたが、今問題が解決しています。コンテナを削除してreset()を呼び出した後、確認画面が消えるようになりました。ありがとうございました。 – Junto

+0

私はちょうど "これは一般的に[...]"という文脈を維持したいと思っていました;)うれしいことです:) – Ezenhis

+0

私はChromeでリセットが必要ないことに気づき、代わりにJavascriptエラーですが、IEでは必要です。だから私はそれがIEであるかどうかを確認するためのチェックがあり、そうであればリセットを実行するだけです。 – Junto

関連する問題