Created
August 28, 2019 03:03
-
-
Save sudikrt/85be43fb9320d98e45e826b1a3ba88a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<iframe> | |
<html> | |
<head> | |
<script src='https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit' /> </script> | |
<script type="text/javascript"> | |
var callPostMethod = function (action, response) { | |
var hostURL = window.location.origin; | |
parent.postMessage({ action: action, response : response }, hostURL); | |
} | |
var onVerifyCallback = function () { | |
let val = document.getElementById("g-recaptcha-response").value; | |
callPostMethod ('verified', val); | |
}; | |
var onErrorCallback = function () { | |
let val = document.getElementById("g-recaptcha-response").value; | |
callPostMethod ('error', val); | |
}; | |
var onExpiredCallback = function () { | |
let val = document.getElementById("g-recaptcha-response").value; | |
callPostMethod ('expired', val); | |
}; | |
var onloadCallback = function() { | |
console.log ('Loaded'); | |
callPostMethod ('loaded', ''); | |
grecaptcha.render('recaptcha-div', { | |
'sitekey' : 'YOURKEY', | |
'theme' : 'light', | |
'callback' : onVerifyCallback, | |
'expired-callback' :onExpiredCallback, | |
'error-callback' : onErrorCallback | |
}); | |
}; | |
</script> | |
</head> | |
<body> | |
<div id="recaptcha-div" class="g-recaptcha recaptcha"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment