Problem when using iframe SecurityError

0

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

The team asked me for an iframe for implementation in the portals and web-sites but when I did a test it presents the following error:

  

SecurityError: Blocked a frame with origin " link " from accessing a cross-origin frame.

The iframe is in a test.html file that is running on localhost, every Ajax request only works when I submit a form in a form.

Does anyone know how to solve it?

    
asked by anonymous 29.03.2017 / 02:54

2 answers

1

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

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

  

I have modified 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 giving error):

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

                    } else {
                          console.log("WARNING >>>", "systemForms.beforeSend not exists!");
                    }
                },
    
29.03.2017 / 15:32
0

You must use the CORS , the server you are receiving should send the following HTTP header back.

Access-Control-Allow-Origin: seudominio

If you are the Apache server, just follow these instructions .

    
29.03.2017 / 03:45