Call back between two sites - link between two sites

I have a web application in http: //domain1/app1/called.html and I want to embed this application in http: //domain2/app2/caller.html with iframe (or popup, this is the same)

the user should be able to interact with named.html until you click on a specific button, in this case I need to tell caller.html that the user has selected an element from named.html

I tried to implement it using javascript.

in called.html I encode the data in json and then run the call_callback javascript function in caller.html, passing json as a parameter.

if the called .html call is called with a popup, I give out window.opener.called_callback (jsonData), if it's an iframe, I just give parent.called_callback (jsonData)

having caller.html and named.html in the same domain, everything works fine, but from different domains I get the following errors:

permission denied (on IE6)

and

Unsafe JavaScript attempt to access frame with URL [..]/caller.html from frame with URL [...]called.html. Domains, protocols and ports must match. (on google chrome)

Can this limitation be overcome?

What other way to achieve this can you imagine?

I think caller.html could implement a web service, and I could send the result calling it, but the caller.html page would have to poll to detect any changes ...

So, how can one application interact with another in another domain to signal an event ???

+3
source share
4 answers

Thanks to the answer, I found the following:

http://benalman.com/code/projects/jquery-postmessage/docs/files/jquery-ba-postmessage-js.html

http://benalman.com/projects/jquery-postmessage-plugin/

jQuery postMessage . , (FF3, Safari 4, IE8), document.location.hash (IE6, IE7, Opera).

window.postMessage, JavaScript , . , isnt . , child Iframe .

...

+1
+4

JSONP. jQuery, . JSON .

+1

Source: https://habr.com/ru/post/1783289/


All Articles