"13" JavaScript cross-domain communication

Source: Internet
Author: User
Tags event listener

JavaScript cross-domain communication

Homologous: Two documents of the same origin need to meet

    1. Same protocol
    2. Same domain name
    3. 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 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

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.