<tfoot id='rQ5n6'></tfoot>

      • <bdo id='rQ5n6'></bdo><ul id='rQ5n6'></ul>
      <legend id='rQ5n6'><style id='rQ5n6'><dir id='rQ5n6'><q id='rQ5n6'></q></dir></style></legend>

        <small id='rQ5n6'></small><noframes id='rQ5n6'>

        <i id='rQ5n6'><tr id='rQ5n6'><dt id='rQ5n6'><q id='rQ5n6'><span id='rQ5n6'><b id='rQ5n6'><form id='rQ5n6'><ins id='rQ5n6'></ins><ul id='rQ5n6'></ul><sub id='rQ5n6'></sub></form><legend id='rQ5n6'></legend><bdo id='rQ5n6'><pre id='rQ5n6'><center id='rQ5n6'></center></pre></bdo></b><th id='rQ5n6'></th></span></q></dt></tr></i><div id='rQ5n6'><tfoot id='rQ5n6'></tfoot><dl id='rQ5n6'><fieldset id='rQ5n6'></fieldset></dl></div>

        在模态或对话框内时,IE 中的新 Google reCAPTCHA 出现问题

        Problems with new Google reCAPTCHA in IE when inside modal or dialog(在模态或对话框内时,IE 中的新 Google reCAPTCHA 出现问题)

          <tfoot id='5jTcy'></tfoot>
                <tbody id='5jTcy'></tbody>

              • <bdo id='5jTcy'></bdo><ul id='5jTcy'></ul>

                <i id='5jTcy'><tr id='5jTcy'><dt id='5jTcy'><q id='5jTcy'><span id='5jTcy'><b id='5jTcy'><form id='5jTcy'><ins id='5jTcy'></ins><ul id='5jTcy'></ul><sub id='5jTcy'></sub></form><legend id='5jTcy'></legend><bdo id='5jTcy'><pre id='5jTcy'><center id='5jTcy'></center></pre></bdo></b><th id='5jTcy'></th></span></q></dt></tr></i><div id='5jTcy'><tfoot id='5jTcy'></tfoot><dl id='5jTcy'><fieldset id='5jTcy'></fieldset></dl></div>
              • <legend id='5jTcy'><style id='5jTcy'><dir id='5jTcy'><q id='5jTcy'></q></dir></style></legend>

                <small id='5jTcy'></small><noframes id='5jTcy'>

                  本文介绍了在模态或对话框内时,IE 中的新 Google reCAPTCHA 出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  reCAPTCHA 在 Chrome 中运行良好.

                  reCAPTCHA works perfectly well in Chrome.

                  但是,(仅当 reCAPTCHA iframe 在对话框或模式中时)在 IE 中占位符不会消失.

                  However, (only when reCAPTCHA iframe is inside a dialog box or a modal) in IE the placeholder won't go away.

                  无论用户写什么都被认为是占位符的一部分(我认为),并且验证"按钮不会被点击.

                  Whatever the user writes is considered part of the placeholder (I think) and the "verify" button won't be enabled to be clicked.

                  图片说明了这一点:

                  当我将 recaptcha div 放在模态框之外时,相同的代码在所有浏览器中都运行良好

                  The same code works perfectly well in all browsers when I take the recaptcha div outside the modal

                  <html lang="en">
                  <head>
                      <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
                      <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
                      <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
                      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
                      <script type="text/javascript">
                      var onloadCallback = function() {
                          grecaptcha.render('html_element', {
                            'sitekey' : '6Lc7PAATAAAAAE7JwcA7tNEDIrczjCCUvi3GiK4L'
                        });
                      };
                      </script>
                  </head>
                  <body>
                      <div class="container">
                          <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
                            Launch modal
                        </button>
                        <!-- Modal -->
                        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                              <div class="modal-content">
                                  <form action="?" method="POST">
                                    <div id="html_element"></div>
                                    <br>
                                    <input type="submit" value="Submit">
                                </form>
                            </div>
                        </div>
                    </div>
                  </div>
                  </body>
                  </html>
                  

                  推荐答案

                  问题是由Bootstrap的modal组件产生的.

                  The problem is generated by the the modal component of Bootstrap.

                  当模态即将出现时,调用此函数:

                  When the modal is about to appear this function is called:

                  Modal.prototype.enforceFocus = function () {
                      $(document)
                      .off('focusin.bs.modal') // guard against infinite focus loop
                      .on('focusin.bs.modal', $.proxy(function (e) {
                          if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
                              this.$element.trigger('focus')
                          }
                      }, this))
                  }
                  

                  该函数向文档添加focusin"事件以确保焦点仍在模态框内;如果焦点转到模态之外的另一个元素,则后者立即将其取回.
                  因此,当您在 recaptcha 表单内单击时,焦点冲突会导致 Internet Explorer 错误.

                  The function adds a "focusin" event to the document to be sure that the focus is still inside the modal; if the focus goes to another element outside the modal then the latter immediately obtain it back.
                  Therefore, when you click inside the recaptcha form the focus' conflict causes the Internet Explorer bug.

                  无论如何,一种可能的解决方案是在recaptcha 组件获得焦点时覆盖该方法并禁用焦点返回行为,但这很难做到,因为无法控制recaptcha html(你怎么知道如果e.target 是recaptcha 的一个元素?).

                  Anyway, one possible solution is to override that method and disable the focus-back behaviour when a recaptcha component obtain the focus, but this is quite difficult to do because there is no control over the recaptcha html (how can you know if e.target is an element of recaptcha?).

                  我的解决方案是完全禁用此行为,为此只需使用空函数覆盖 enforceFocus 函数:

                  My solution is to completely disable this behavior, to do this just override the enforceFocus function with an empty function:

                  $.fn.modal.Constructor.prototype.enforceFocus = function () { };
                  

                  希望有更优雅的解决方案.:)

                  A more elegant solution would be apreciated. :)

                  这篇关于在模态或对话框内时,IE 中的新 Google reCAPTCHA 出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  使用layui的时候出现Uncaught ReferenceError: layui is not defined 遇到这种错误要怎么处理呢? 第一:排查引入的js路径是否正确 第二:检查你的form里面的class是否设置了class=layui-form,这样才是真正声明一个form表单
                  在做前端时候,遇到一个js错误:Uncaught SyntaxError: Unexpected string,这种通常什么原因造成的,该如何解决呢? 解决办法: 1. jQuery有问题?引用的jQuery有冲突? 然后就去首页和分页面检查引用的jQuery,发现首页和分页面引用两个不同版本的jQuery,
                  layui怎么刷新当前页面?下面本篇文章给大家介绍一下layui提交成功之后刷新当前页、关闭当前页、刷新父页、重载父页数据表格的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。 刷新当前页: layer.msg(data.msg, {icon:1,time:1000}
                  What are valid deviceNames for Chrome emulation testing with Protractor?(使用 Protractor 进行 Chrome 模拟测试的有效设备名称是什么?)
                  Protractor Check if Element Does Not Exist(量角器检查元素是否不存在)
                  Protractor e2e Tests Login Redirection(Protractor e2e 测试登录重定向)
                  <i id='XZFJd'><tr id='XZFJd'><dt id='XZFJd'><q id='XZFJd'><span id='XZFJd'><b id='XZFJd'><form id='XZFJd'><ins id='XZFJd'></ins><ul id='XZFJd'></ul><sub id='XZFJd'></sub></form><legend id='XZFJd'></legend><bdo id='XZFJd'><pre id='XZFJd'><center id='XZFJd'></center></pre></bdo></b><th id='XZFJd'></th></span></q></dt></tr></i><div id='XZFJd'><tfoot id='XZFJd'></tfoot><dl id='XZFJd'><fieldset id='XZFJd'></fieldset></dl></div>
                • <small id='XZFJd'></small><noframes id='XZFJd'>

                    <tbody id='XZFJd'></tbody>

                    • <legend id='XZFJd'><style id='XZFJd'><dir id='XZFJd'><q id='XZFJd'></q></dir></style></legend>
                      <tfoot id='XZFJd'></tfoot>
                          <bdo id='XZFJd'></bdo><ul id='XZFJd'></ul>