Due to the restrictions of the same-origin policy, cross-domain communication has always been a thorny issue in JavaScript. Of course, there are many solutions:
1. The setting of the document.domain iframe applies to the same main domain but different subdomains;
2. Using iframe and location.hash, the data is directly exposed in the URL, and the data capacity and types are limited
3.Flash LocalConnection, objects can communicate in one SWF file or between multiple SWF files, as long as
are on the same client, across applications, and across domains.
window.name saves data and cross-domain iframe static proxy dynamic transmission scheme makes full use of the feature of window.name that the name does not change because the URL of the page changes.
There are many example codes for various solutions on the Internet, you can search for them yourself.
One of the coolest APIs in html5: Cross Document Messaging. Advanced browsers Internet Explorer 8, chrome, Firefox, Opera and Safari will all support this feature. The implementation of this function is also very simple, mainly including the "message" event for receiving information and the "postMessage" method for sending messages.
The "postMessage" method of sending a message
Send a message to the external window: