0

When I click the box to confirm I am not a robot, the blue spinner starts spinning but never stops. Eventually the error "Error: Permission denied to access property" appears in the browser console, followed by a (seemingly) random 10 -15 character string, e.g. "rne4xiajwyh".

My code:

<script type="text/javascript">
  var onloadCallback = function() {
    grecaptcha.render('html_element', {
      'sitekey' : 'my_site_key'
    });
  };
</script>

<form action="#" method="POST">
  <div id="html_element"></div>
  <br>
  <input type="submit" value="Submit">
</form>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
    async defer>
</script>

I'm struggling to fix this as I can't find any solutions online, and am unsure how to debug it. Any help would be much appreciated.

Thanks

EDIT: Error message in chrome:

Uncaught DOMException: Blocked a frame with origin "https://www.google.com" from accessing a cross-origin frame.
    at Dp.f.Ub (https://www.gstatic.com/recaptcha/api2/r20170213115309/recaptcha__pl.js:349:353)
    at Dp.vb (https://www.gstatic.com/recaptcha/api2/r20170213115309/recaptcha__pl.js:345:59)
  • ... ... [Error: Permission denied to access property “document”](https://stackoverflow.com/questions/36333978/error-permission-denied-to-access-property-document) – klazeee Dec 12 '18 at 13:24

2 Answers2

1

<head> ... <META HTTP-EQUIV="Access-Control-Allow-Origin" CONTENT="http://www.example.org"> ... </head>

Error: Permission denied to access property “document”

klazeee
  • 11
  • 1
0

It looks like you have to allow cross domain requests:

If you run apache (it might also be pasted in the .htaccess):

<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin https://www.gstatic.com
</IfModule>

Or with php:

header("Access-Control-Allow-Origin: https://www.gstatic.com");

Or with nginx (server part):

add_header Access-Control-Allow-Origin https://www.gstatic.com; # < this is the needed header
Antho
  • 35
  • 9