跨域问题解决方案【后续会慢慢补充详解随笔】

1. 牛客网大厂前端面经常客了属于是,上一篇随笔记录了 CORS 解决跨域问题,这里再介绍几种.

2. 跨域问题解决方案:

【1】CORS 跨域资源共享:在服务器端设置一个 Response Header :Access-Control-Allow-Origin 的值设置为希望访问此服务器资源的源,或者设置为星号【出于安全问题考虑,不建议使用星号】让所有源可以访问此服务器资源.

【2】JSONP

【3】Web Sockets

【4】window.name + iframe

【5】postMessage

【6】location.hash + iframe

【7】document.domain + iframe

【8】动态创建script

posted @ 2021-10-01 16:35  TwinkleG  Views(32)  Comments(0)    收藏  举报