Home > Article > Backend Development > javascript - What are the methods of cross-domain implementation?
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?
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:
The mainstream ones include cors, HTML5 postmessage, josnp, and server proxy
I happened to see a summary: Front-end cross-domain and its solutions