【问题标题】:reCaptcha blocked frame (SOP?)reCaptcha 阻止帧 (SOP?)
【发布时间】:2017-06-08 17:57:20
【问题描述】:

得到一个 Typo3 安装,我已将 Google 的 reCaptcha 添加到表单中。

在其他 Typo3 安装上是否已经成功,但这一次,我在浏览器中收到了被阻止的帧错误。

Blocked frame with origin "https://www.google.com" from accessing a cross-origin frame.
  at um.f.hc (https://www.gstatic.com/recaptcha/api2/....)

这发生了两次,之后,我在前端得到这个按摩。

请升级到支持的浏览器以获得 reCAPTCHA 挑战。

或者,如果您认为此页面有误,请检查您的互联网连接并重新加载。

为什么这会发生在我身上?

这发生在我检查过的所有浏览器(Chrome、FF、IE11)中。

为了包含 reCaptcha,我在模板中添加了以下内容:

  <script src="//www.google.com/recaptcha/api.js" async defer></script>
  <script type="text/javascript">
    var captchaCallback = function() { document.getElementById("captchaResponse").value = document.getElementById("g-recaptcha-response").value }
    var onSuccess = function(response) {
      var errorDivs = document.getElementsByClassName("recaptcha-error");
      if (errorDivs.length) {
        errorDivs[0].className = "";
      }
      var errorMsgs = document.getElementsByClassName("recaptcha-error-message");
      if (errorMsgs.length) {
        errorMsgs[0].parentNode.removeChild(errorMsgs[0]);
      }
      captchaCallback();
      document.getElementById("fhcallback").submit();
    };
  </script>
  <input type="hidden" id="captchaResponse" name="fhcb[recaptcha]" value="" />
  <div id="recaptcha-demo" class="g-recaptcha" data-sitekey="[MYPUBLICKEY]" data-callback="onSuccess" data-bind="inp-submit"></div>
  <button class="orderButton bold" id="inp-submit" ###submit_nextStep###>Senden</button>

在 PHP 中:

$secret = '[MYSECRETKEY]';
$url = 'https://www.google.com/recaptcha/api/siteverify';
$apiResponse = json_decode(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($url.'?secret='.$secret.'&response='.$this->gp[$this->formFieldName]), true);
if($apiResponse['success'] == FALSE) {
    $checkFailed = $this->getCheckFailed();    
}

表单在页面加载时不可见。单击其切换元素后,它会在页面右侧滑入。

我没有想法,客户已经在烦我了。

【问题讨论】:

    标签: recaptcha same-origin-policy


    【解决方案1】:

    我找到了问题。在此安装中,JavaScript 库 Mootools 被包括在内。

    在删除 Mootools 的包含后,不再出现阻止帧的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-08
      • 2015-05-13
      • 2021-08-28
      • 2017-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多