@@ -42,27 +42,44 @@ <h1> In APP Web Client for TestCaptcha Deployment</h1>
4242
4343< h1 > In APP Web Client for TestCaptcha Deployments</ h1 >
4444< p > < a id ="editThisPageLink " target ="_blank " style ="color:blue "> Edit this page</ a > </ p >
45- < style >
46- .embeddedMessagingGRecaptchaBanner {
47- display : none;
48- }
49- </ style >
50- < script >
51- document . getElementById ( 'editThisPageLink' ) . href = "https://github.com/shreerammohanty/miawtest/edit/master/1ShreeRam/LocalSdb6Connect.html" ;
52- </ script >
53- <!-- reCAPTCHA v3 script -->
54- < script src ="https://www.google.com/recaptcha/api.js?render=6Lfy2HMrAAAAAIVf2zhrlxQ-6ht07tNdfNUrD3p9 "> </ script >
5545
56- <!-- Initialize reCAPTCHA v3
46+ < script src =" https://www.google.com/recaptcha/api.js?onload=onRecaptchaLoad&render=explicit " async defer > </ script >
5747< script >
58- grecaptcha.ready(function() {
59- grecaptcha.execute('6Lfy2HMrAAAAAIVf2zhrlxQ-6ht07tNdfNUrD3p9', {action: 'homepage'}).then(function(token) {
60- // You can use the token in your backend verification
61- console.log('reCAPTCHA v3 token:', token);
48+
49+ document . getElementById ( 'editThisPageLink' ) . href =
50+ "https://github.com/shreerammohanty/miawtest/edit/master/1ShreeRam/LocalSdb6Connect.html" ;
51+
52+ let recaptchaWidgetId = null ;
53+
54+ function onRecaptchaLoad ( ) {
55+ recaptchaWidgetId = grecaptcha . render ( 'recaptcha-container' , {
56+ sitekey : '6Lfy2HMrAAAAAIVf2zhrlxQ-6ht07tNdfNUrD3p9' ,
57+ size : 'invisible' ,
58+ callback : onVerify ,
59+ 'error-callback' : onError ,
60+ 'expired-callback' : onExpired
6261 } ) ;
63- });
62+
63+ // Execute immediately, no button required
64+ grecaptcha . execute ( recaptchaWidgetId ) ;
65+ }
66+
67+ function onVerify ( token ) {
68+ console . log ( 'reCAPTCHA token:' , token ) ;
69+ // TODO: POST the token to your backend for verification
70+ // fetch('/verify', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ token }) });
71+ }
72+
73+ function onError ( ) {
74+ console . error ( 'reCAPTCHA error' ) ;
75+ }
76+
77+ function onExpired ( ) {
78+ console . warn ( 'reCAPTCHA expired, re-executing…' ) ;
79+ grecaptcha . execute ( recaptchaWidgetId ) ;
80+ }
6481</ script >
65- -->
82+
6683
6784< script type ='text/javascript '>
6885 function initEmbeddedMessaging ( ) {
0 commit comments