JavaScript homology policy

Source: Internet
Author: User

What is a homologous strategy?

The same-origin policy is a complete security restriction on JavaScript code that can manipulate those web content. This strategy can work when a Web page uses multiple IFRAME elements or opens multiple forms.

Understand the same origin policy: script source and document source.

Script source:<script> javascript src= "http (s)://..." Source.

Document Source: Contains: protocol, host, and URL port number of the loaded document. Documents that are loaded from different Web servers have different sources.

It is important to understand these two points.

Document Source: 1. Documents loaded from different ports on the same host have different sources.

2. Loading documents on the same server via HTTP and HTTPS has different sources.

3, above three points can not be the same.

Script Source: 1, the script from host A is included in the <script> of Host B in the web, the source of this script is B,

2, the script opens a new form, loads the document of Host B, the script has full access rights.

3, the script opens a new form, loads the document of host C, the same-origin policy will prevent the script from accessing this document.

The same-origin strategy adapts to almost all JavaScript object properties.

? 1 The same-origin policy can cause problems for large sites with multiple subdomains.

1. Load the documents under other subdomains. Document hierarchy change domain, for example: home.example.com, domain can be set to: example.com, can.

Set the script for another document to be accessed to the same domain.

2. Cross-domain resource sharing (cross-origin Resource sharing), see: Cross-domain resources

3. Cross-document messages (Cross-document messing).

Code: You crossing, I understand and then write ...

JavaScript homology policy

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.