javascript - ReCAPTCHA ajax加载主题问题

标签 javascript jquery themes recaptcha getscript

无法弄清楚如何为 ajax 加载的 recaptcha 设置主题。下面的代码不起作用。
来自 Google Recaptcha

看到这篇文章 Recaptcha ajax API custom theme not working , 但我肯定是在本地主机上查看并且 recaptcha 工作正常,只是没有改变主题。

有人对如何使用白色主题有建议吗?

    <script type='text/javascript'>
        var RecaptchaOptions = {
            theme : 'white'
         };
    </script>
    <div id="recaptcha_content">
      <noscript>
        <iframe src="http://www.google.com/recaptcha/api/noscript?k=6Ldr7woAAAAAADa_69Mr-EZKAeYyEx9N08q" height="300" width="500" frameborder="0"></iframe><br />
        <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
        <input type='hidden' name='recaptcha_response_field' value='manual_challenge' />
      </noscript>
    </div>
    <script type="text/javascript">
    $(document).ready(function() {
        $.getScript('http://www.google.com/recaptcha/api/js/recaptcha_ajax.js',
            function() {Recaptcha.create("6Ldr7woAAAAAADa_69Mr-EZKAeYyEx9N08q", "recaptcha_content");
        });

    });
    </script>

最佳答案

@jhanifen:在使用 http://wiki.recaptcha.net/index.php/Installation 中的大部分代码后,我开始工作了,试试这个——

<html>
    <head>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
    </head>

    <body>

    <script type="text/javascript">
    $(document).ready(function() {
        $.getScript('http://www.google.com/recaptcha/api/js/recaptcha_ajax.js',
            function() {
                Recaptcha.create("6Ldr7woAAAAAADa_69Mr-EZKAeYyEx9N08q", 
                "recaptcha_content",
                {
                    theme: "white", 
                    callback: Recaptcha.focus_response_field
                }
            );
        });
    });
    </script>

    <div id="recaptcha_content">
      <noscript>
        <iframe src="http://www.google.com/recaptcha/api/noscript?k=6Ldr7woAAAAAADa_69Mr-EZKAeYyEx9N08q" height="300" width="500" frameborder="0"></iframe><br />
        <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
        <input type='hidden' name='recaptcha_response_field' value='manual_challenge' />
      </noscript>
    </div>

    </body>
</html>

关于javascript - ReCAPTCHA ajax加载主题问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5279069/

相关文章:

javascript - 了解 Ajax 成功回调如何在此 ReactJS 示例中更新状态

javascript - 如何在javascript中输入名称和id的值?

PHP 错误 : Notice: Undefined variable

javascript - jQuery next() 在哪里使用它

eclipse - 在Eclipse中编辑代码时如何禁用粗体字体?

android - 如何创建自定义主题并在 Android 应用程序中使用它?

javascript - 父选择器 Jquery

javascript - 无法使用 jQuery 定位嵌入式 Flickr 视频 iframe

Javascript 多个 OR 在 if 条件中使用 for 循环

wpf - 尝试继承主题/风格并应用额外的触发器