One, window. PostMessage is suitable for cross domain communication within different windows of the same page. This method allows you to communicate across windows, regardless of whether the two windows are homologous. Second, for example, the parent window http://127.0.0.1:3000/index.html to the child window http://127.0.0.1:3001/index.html send a message, call the PostMessage method on the line. (who sends the message, first gets its window object, such as the parent window sends a message to the child window, first gets the child window object, and then calls the PostMessage method) as follows:
Window.postmessage (Messages, origin) message: Specific Information content origin: the source of receiving messages four, Window.addeventlistener (' message ', callback, False) listens to messages sent by the other side by listening for message events. Callback:function (event) {}//event three properties are {Source: The window that sends the message origin: the domain name of the message sent: message sent}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.