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!