Help with this error “Blocked a frame with origin “” from accessing a cross-origin frame”


Help with this error “Blocked a frame with origin “” from accessing a cross-origin frame”

Using drupal, I've got a parent page with an iframe. On the iFrame page, I have a checkbox which shows more fields on click but it gets cut off because the div height on the parent page is less than what the iframe height expands to.

The script below should increase the height of the div on the parent page.

$(document).ready(function() { $(document.querySelectorAll('[name="mx_CR_Mail_Prospectus"]')).click(function() { if (typeof hidden === 'undefined' || hidden == true) { $(document.querySelectorAll('[data-field-name="mx_Street1"]')).show(250); $(document.querySelectorAll('[data-field-name="mx_Contact_Suburb"]')).show(250); $(document.querySelectorAll('[data-field-name="mx_Contact_Postcode"]')).show(250); $(document.querySelectorAll('[data-field-name="mx_State"]')).show(250); $(document.querySelectorAll('[data-field-name="mx_Country"]')).show(250); hidden = false; $('#book', window.parent.document).height('1287px'); } else { $(document.querySelectorAll('[data-field-name="mx_Street1"]')).hide(250); $(document.querySelectorAll('[data-field-name="mx_Contact_Suburb"]')).hide(250); $(document.querySelectorAll('[data-field-name="mx_Contact_Postcode"]')).hide(250); $(document.querySelectorAll('[data-field-name="mx_State"]')).hide(250); $(document.querySelectorAll('[data-field-name="mx_Country"]')).hide(250); hidden = true; $('#book', window.parent.document).height('927px'); } }); }); 

When I click on the checkbox, I get the following error "Uncaught DOMException: Blocked a frame with origin "http://mywebsite.com" from accessing a cross-origin frame".

After a bit of research, I know there's a cross-origin policy that prevents JS interaction so I proceeded to change the "CORS" config in the default.services.yml file as seen below.


Note: By default the configuration is disabled.

cors.config: enabled: true

Specify allowed headers, like 'x-allowed-header'.

allowedHeaders: ['*']

Specify allowed request methods, specify ['*'] to allow all possible ones.

allowedMethods: ['*']

Configure requests allowed from specific origins.

allowedOrigins: ['*']

Sets the Access-Control-Expose-Headers header.

exposedHeaders: false

Sets the Access-Control-Max-Age header.

maxAge: 1000

Sets the Access-Control-Allow-Credentials header.

supportsCredentials: false


Even though I enabled CORS, I'm still getting the same error. Does anyone have any suggestions?

Submitted July 17, 2017 at 11:49AM by chickenfingers777
via reddit http://ift.tt/2vswhE3

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s