Home  >  Article  >  Backend Development  >  javascript - What are the methods of cross-domain implementation?

javascript - What are the methods of cross-domain implementation?

WBOY
WBOYOriginal
2016-08-08 09:07:031019browse

1. Through IFRAME
2. Through JSONP
3. Set http header, Access-Control-Allow-Origin:*
4. Server proxy
5. nginx reverse proxy to achieve cross-domain

Anything to add?

Reply content:

1. Through IFRAME
2. Through JSONP
3. Set http header, Access-Control-Allow-Origin:*
4. Server proxy
5. nginx reverse proxy to achieve cross-domain

Anything to add?

How can we not have PHP’s powerful tool class, curl. How perfect can we achieve with this

<code>window.name</code>

Set Access-Control-Allow-Origin:* should belong to CORS

Use window.navigator for cross-domain
This solution can only be used in ie6 and ie7
because there is a bug in ie6 and ie7. That is, the navigator of the parent page and the child page are shared.

General solutions are postMessage, <code>window.name</code>, window.navigator.

postMessage is used in standard browsers.
<code>window.name</code> and window.navigator are used in ie, but the implementation of <code>window.name</code> must regularly check whether name has changed, while navigator does not exist.

feature detection The priority is postMessage, navigator, name.

See the picture below:

javascript - What are the methods of cross-domain implementation?

The mainstream ones include cors, HTML5 postmessage, josnp, and server proxy

I happened to see a summary: Front-end cross-domain and its solutions

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn