A
A
Alexander Razumov2015-09-02 13:26:11
Google
Alexander Razumov, 2015-09-02 13:26:11

How to display google recaptcha dynamically?

Good day!
Tell me how to make it so that when you click on a link on the page, recaptcha is dynamically loaded.
Right now, when clicked, only a div block is created - And it remains empty, nothing is displayed. On click:
<div id="recaptcha2"></div>
481ca0d5d4a34855bf94b201dee29026.jpg
079a4ed96e354cd7b6f293cb985c045f.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
magazovski, 2015-09-02
@magazovski

Here is the documentation: call the grecaptcha.render method

<html>
  <head>
    <title>reCAPTCHA demo: Explicit render after an onload callback</title>
    <script type="text/javascript">
      var onloadCallback = function() {
        grecaptcha.render('html_element', {
          'sitekey' : 'your_site_key'
        });
      };
    </script>
  </head>
  <body>
    <form action="?" method="POST">
      <div id="html_element"></div>
      <br>
      <input type="submit" value="Submit">
    </form>
    <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
        async defer>
    </script>
  </body>
</html>

A
Alexander Razumov, 2015-09-03
@razumovsu

thanks for reprinting the google documentation!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question