Cross-domain issues with different ports on the same web system

Source: Internet
Author: User

When deploying a web system, a cross-domain problem was discovered, and the subsystem was embedded in the system with an IFRAME, causing the parent window to get the webservice and picture of the subsystem to discover cross-domain issues, as shown in:
Issue 1: Parent window gets subsystem objects across domains

reason: passing parameters directly in this way involves cross-domain issues

Parent Form pass Parameters:

Window. Monitorstationinfo.id= selectedrow.id; // parent Form pass Parameters

The subform Gets the parameters:

var pointid=window.parent.parent.monitorstationinfo.id// sub-form get parameters

Workaround: use cookies to pass parameters

Parent Form pass Parameters:

Document.cookie = "pointid=" + Escape (row. Monitorid); // Parent Forms Save parameters with cookies

The subform Gets the parameters:

  var arr = Document.cookie.match (new RegExp ("(^|) Pointid= ([^;] *)(;|$)"));   var pointid = unescape (arr[2]); // The subform Gets the parameters passed by the parent page through the cookie .

Issue 2: A picture of a subsystem source is displayed in the parent form across domains


When you click the picture in the Subwindow, the enlarged picture pops up in the parent window, as shown in:

before clicking:

After clicking

Actual effect:

Reason:

When using jquery to dynamically load enlarged images, I used the system's top-level document (Top.document) to manipulate the DOM's

This causes the enlarged picture to be displayed in the parent form resulting in cross-domain

Workaround:

let the magnified picture appear in the subsystem: when using jquery to dynamically load enlarged images, use the subsystem's document (Window.parent.document) to manipulate the DOM's

Cross-domain issues with different ports on the same web system

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.