前端面试 跨域理解

2 实现

2-1 JSONP 实现

2-2 nginx 配置

2-2 vue 开发中 webpack自带跨域

2 -3 下载CORS 插件 或 chrome浏览器配置跨域

2-4 通过iframe

如:aaa.com 中读取bbb.com的localStorage

1)在aaa.com的页面中,在页面中嵌入一个src为bbb.com的iframe,此时这个iframe里可以调用bbb.com的localStorage。

<iframe id="bbb-iframe" src="https://bbb.com/page1.html" style="display:none;"></iframe>

2)用postMessage方法实现页面与iframe之间的通信。

相关推荐
sasaraku.32 分钟前
serviceWorker缓存资源
前端
RadiumAg2 小时前
记一道有趣的面试题
前端·javascript
yangzhi_emo2 小时前
ES6笔记2
开发语言·前端·javascript
yanlele2 小时前
我用爬虫抓取了 25 年 5 月掘金热门面试文章
前端·javascript·面试
中微子3 小时前
React状态管理最佳实践
前端
烛阴3 小时前
void 0 的奥秘:解锁 JavaScript 中 undefined 的正确打开方式
前端·javascript
中微子3 小时前
JavaScript 事件与 React 合成事件完全指南:从入门到精通
前端
Hexene...3 小时前
【前端Vue】如何实现echarts图表根据父元素宽度自适应大小
前端·vue.js·echarts
天天扭码4 小时前
《很全面的前端面试题》——HTML篇
前端·面试·html
xw54 小时前
我犯了错,我于是为我的uni-app项目引入环境标志
前端·uni-app