reCapcha中被阻止的帧

tim*_*tim 6 javascript recaptcha

我在本地测试服务器上使用reCapcha.一切正常,但我有错误:

Blocked a frame with origin "https://www.google.com" from accessing a frame with origin "http://127.0.0.1:8000".  The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.
Run Code Online (Sandbox Code Playgroud)

Blocked a frame with origin "https://www.google.com" from accessing a frame with origin "http://127.0.0.1:8000".  The frame requesting access has a protocol of "about", the frame being accessed has a protocol of "http". Protocols must match.
Run Code Online (Sandbox Code Playgroud)

在HTML中:

...
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
...
<div class="g-recaptcha" data-sitekey="..."></div>
Run Code Online (Sandbox Code Playgroud)

如何解决这些错误?

谢谢!

rab*_*ill 1

如果您使用 iframe,这部分:

阻止具有来源 [此处 url] 的框架访问具有来源 [此处其他 url] 的框架。

意味着它不会起作用。帧不能互相干扰,否则人们可以从一帧中窃取另一帧中的数据。查看同源政策了解更多详情。

不过,您也许可以通过消除混合协议错误来简化事情:您可以通过 http 而不是 https 访问 Google 文件,因此尝试这样做可能会消除一半的麻烦。(您也可以只使用这样的 url://www.google.com/recaptcha/api.js而不是指定是使用 http 还是 https。)