前端解决跨域的九种方法(老生常谈的面试题了) 陈进步 2021-07-07 453 阅读1分钟 跨域解决方案 1、 通过jsonp跨域 2、 document.domain + iframe跨域 3、 location.hash + iframe 4、 window.name + iframe跨域 5、 postMessage跨域 6、 跨域资源共享(CORS) 7、 nginx代理跨域 8、 nodejs中间件代理跨域 9、 WebSocket协议跨域 通过jsonp跨域 基本原理: 主要就是利用了 script 标签的src没有跨域限制来完成的。