0

I have two web applications where I need to send some text data from one applicatio to another.

From my first app trying to open second app using window.open(url). from second app calling below method on click event that is send_report_data which will have all the data and then pasing to parent window.

function send_report_data(form_data){
if(opener != null){

    var test_data = form_data;//It has text data


    opener.globalNotify(test_data);//passing to callback
    window.close();//Once passed closing current window

    }

}

var globalNotify = function callback(finaldata){

   $('#post_data_div').html(finaldata);//Recieved text data assigning to text area
   $("#reportingRte").html(finaldata);//Recieved text data assigning to div element 

}

But getting below error at this line opener.globalNotify(test_data);

custom.js:1162 Uncaught DOMException: Blocked a frame with origin "http://one.example.com" from accessing a cross-origin frame.

I tried figuring out from similar posts but not working yet.

Any help would be appreciated.

  • you can't do much with cross origin frames - unless you own both origins, then you can write code that communicates between cross origin frames (window.postMessage) – Bravo Nov 02 '18 at 11:10
  • Ok can you please explain why is it blocking the connection –  Nov 02 '18 at 11:16
  • You need to add an `X-FRAME-OPTIONS` header to the site you're trying to put within the iframe: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options – Rory McCrossan Nov 02 '18 at 11:17
  • It's blocking the connection because cross-site communication is heavily secured on the client side, for fairly obvious reasons. – Rory McCrossan Nov 02 '18 at 11:17
  • Check [here](https://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame) to get more information about your error. Its a realy good explanation. – Fabian Nov 02 '18 at 11:59

0 Answers0