HTML5 new mechanism: PostMessage for secure cross-domain communication (code)

Source: Internet
Author: User
This article brings the content is about HTML5 new mechanism: PostMessage to achieve security cross-domain communication (code), there is a certain reference value, the need for friends can refer to, I hope to help you.

PostMessage parsing

    • HTML5 provides a new mechanism for secure cross-source communication postmessage. Grammar
      Otherwindow.postmessage (Message, Targetorigin, [transfer]);
      Otherwindow: A reference to other windows, such as the Contentwindow property of the IFRAME, execution,
      window.open returns the Window object. Message: The data that will be sent to the other window. Targetorigin:
      The Origin property of the window is used to specify which Windows can receive a message event, whose value can be either the character "*" (which means no limit) or a URL transfer:
      is a string of transferable objects that are passed along with the message. Ownership of these objects will be transferred to the recipient of the message, and sending a drop will no longer retain ownership.

    • Element.addeventlistener (event,fn,usecaption); Three parameter event events such as
      Click MouseEnter MouseLeave callback function usecaption
      Used to describe whether it is bubbling or capturing. The default value is False, which is the bubbling pass. A value of true is the capture pass.

Implementation method

Main interface main.html

<! DOCTYPE html>

IFrame interface

<! DOCTYPE html>
Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.