Through the IFRAME in a Site page embedded blank page, cross-domain to get the data of B site back to a site!

Source: Internet
Author: User
Tags blank page

The following code is just to demonstrate how the method is actually operating, and the actual meaning is not very significant.

In fact, this method can also solve many aspects of cross-domain operations, the following two points for my work encountered in the situation!

For example, a system to open the B system page, get the B system page height, a system can dynamically set the height of the window

There is a system to open the B system page, B system page to perform a series of operations, the successful operation of a system to close the window, you can be successful after the operation of the B system embedded in the blank.html page of a system, blank.html the page open, dynamic shutdown a system window!

Let's talk about how this approach is implemented.

1. Under a system to add a blank page named blank.html, note that no content required, because only need to add JS code inside it!

2. Then we embed the ifrme path to the Home/index page of the B system under the Home/index page of the A system, and add the custom parameter Url,url to the blank page of the a system just added, and the IFrame remembers to add the name and id attribute, Convenient for next operation!

3. This will request the index action under the HomeController controller of B system, receive the URL parameter passed by Viewbag.blankurl=url, return to the page through the page, and dynamically get the height of the page when loading. Then add the Name=iframeblank IFRAME element again in the DIV element of the page and the address points to Viewbag.blankurl, which is the blank page of the A system, and pass through the parameters required by the "#" character segmentation, the symbols can be customized!

4.A system through the IFRAME Embedded B system home/index page at the same time, B system in the page embedded in the blank.html page of a system and the data transmitted by B system, due to the special properties of the IFRAME need to obtain the returned data var by the following way Data= window.parent.parent.frames["MyFrame"].frames["Iframeblank"].location.hash

Through the IFRAME in a Site page embedded blank page, cross-domain to get the data of B site back to a site!

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.