Problem using Securityerror iframe

Asked

Viewed 490 times

0

Good night, I have a form system, and my client wants to put the form on his website.

His team requested me an iframe for implementation on the portals and web-sites but when I did a test presents the following error:

Securityerror: Blocked a frame with origin "http://meucliente.meudominio.com" from accessing a cross-origin frame.

iframe, is in a test.html file that is running on localhost, every Ajax request works only when I give a Submit in a form that this occurs.

Does anyone know how to solve?

2 answers

1


Hello I do not know why it happened but solved my problem.

This error only happened when I tried to typeof inside my beforeSend in ajax.

I modified it to the script below and now it works:

beforeSend: function (xhr) {
                    try {
                        parent.systemForms.beforeSend();
                    } catch (e) {
                        console.log("WARNING >>>", "systemForms.beforeSend not exists!");
                    }
                    return xhr;
                },

Before (when the error occurred):

beforeSend: function () {
                    if(typeof parent.systemForms != 'undefined') {
                          parent.systemForms.beforeSend();

                    } else {
                          console.log("WARNING >>>", "systemForms.beforeSend not exists!");
                    }
                },

0

You must use the CORS, the server that is receiving should send back the following HTTP header.

Access-Control-Allow-Origin: seudominio

If you are a server Apache just follow these instructions.

  • Hi Lucas, I’ve tried using CORS. It’s not the problem, it’s something in iframe security, sandbox something like that.

  • Nor is an HTTP request of type "Options" to analyze it.

  • @Hiagosouza, could you explain more about the.html test being in localhost? Your Submit in this case makes a request for which domain?

  • hello Thanks, but I have already located the problem. The Solution is in the answer I left.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.