javascript - Google ReCaptcha Uncaught DOMException: Blocked a frame with origin "https:www.google.com" - Stac

I'm not sure why this is happening, and it isn't the usual, mon error of:Uncaught SecurityErr

I'm not sure why this is happening, and it isn't the usual, mon error of:

Uncaught SecurityError: Block a frame with origin.

The error I'm getting is:

Uncaught DOMException: Blocked a frame with origin "" from accessing a cross-origin frame.

I'm following Google's instructions on how to enable ReCaptcha, but it isn't working for me!

// top of the page
<script src=".js" async defer></script>
// then somewhere in the bottom
<div class="g-recaptcha" data-sitekey="@Model.Register.CaptchaSiteKey"></div>

My CaptchaSiteKey is being loaded (I debugged and checked).

I'm not sure why this is happening, and it isn't the usual, mon error of:

Uncaught SecurityError: Block a frame with origin.

The error I'm getting is:

Uncaught DOMException: Blocked a frame with origin "https://www.google." from accessing a cross-origin frame.

I'm following Google's instructions on how to enable ReCaptcha, but it isn't working for me!

// top of the page
<script src="https://www.google./recaptcha/api.js" async defer></script>
// then somewhere in the bottom
<div class="g-recaptcha" data-sitekey="@Model.Register.CaptchaSiteKey"></div>

My CaptchaSiteKey is being loaded (I debugged and checked).

Share Improve this question edited Jul 3, 2017 at 17:06 halfer 20.4k19 gold badges109 silver badges202 bronze badges asked May 31, 2017 at 15:10 J86J86 15.3k50 gold badges145 silver badges250 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 0

The same-origin policy is an important concept in the web application security model. Under the policy, a web browser permits scripts contained in a first web page to access data in a second web page, but only if both web pages have the same origin. An origin is defined as a bination of URI scheme, hostname, and port number. This policy prevents a malicious script on one page from obtaining access to sensitive data on another web page through that page's Document Object Model.

In other word: recaptcha is an Remote Script resource, and for security issues, your web server not allowing to use external resources code.

https://developer.mozilla/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin

To allow any resource to access your resource, you can specify:

Access-Control-Allow-Origin: *

To allow https://www.google. to access your resource, you can specify:

Access-Control-Allow-Origin: https://www.google.

As explained by the answer here https://stackoverflow./a/29014899/1853802, change all the http(s) protocols on your page to //

e.g.

<script src="http://example1."></script> => <script src="//example1."></script>

<link href="https://example2." /> => <link href="//example2. />

This solved it for me.

NB: Remember to clear your cache afterwards.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744773855a4592924.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信