JavaScript cross-domain communication
Homologous: Two documents of the same origin need to meet
- Same protocol
- Same domain name
- Same port
cross-domain communication methods:
01, by settingimg,script,link,iframe ElementsThe Src,href property is the destination URL. 02, request JSON data, use <script> make JSONP request. 03, set the internal server proxy to request cross-domain URLs. Returns the data. 04,cors function. The HTTP response header for the target server is "access-control-allow-origin:*". Konjac: But it's not safe. You can set a license for a specific Web site. 05, Multi-window communication, via Targetwindow.postmessage (Date,origin)
- data:
- origin: Origin
of the target window
window.addEventListener(‘message‘function(event)false);
Window Add message Event Listener: Event Object
- Event.data is the data sent by PostMessage
- Event.origin is the origin of the sending window
- Event.source is a window reference for sending messages
**
"13" JavaScript cross-domain communication