iframe跨源报错:"Blocked a frame with origin from accessing a cross-origin frame"
2024-10-18 21:22:56
一、报错信息:
“Blocked a frame with origin from accessing a cross-origin frame”
二、在stackoverflow上找到原因
Same-origin security policy You can't access an <iframe> with Javascript, it would be a huge security flaw if you could do it. For the same-origin policy browsers block scripts trying to access a frame with a different origin. (同源策略) Origin is considered different if at least one of the following parts of the address isn't maintained: <protocol>://<hostname>:<port>/path/to/page.html Protocol(协议), hostname(主机名) and port(端口) must be the same of your domain, if you want to access a frame.
iframe调用父页面的函数:parent.functionNme();
ps:如果报以上错误,把iframe和父页面代码都放入工程项目中在本地跑起来即可解决同源问题。
最新文章
- 【超级干货】手机移动端WEB资源整合
- Python 基礎 - 字符轉編碼操作
- 站在移动互联时代的十字路口上_deviceone
- 总结baiduTemplate和djangoTemplate的学习
- [转]Membership 到 .NET4.5 之 ASP.NET Identity
- 屠龙之路_战胜狮身人面怪物_SecondDay
- 你的C#代码是怎么跑起来的(一)
- 将Web应用性能提高十倍的10条建议
- 三种查看SqlServer中数据物理pge页的方法
- 启动MFC程序的时候报错:0xC0000005: 读取位置 0x00000000 时发生访问冲突
- 在Hyper-V虚拟机中使用Wi-Fi上网
- SharePoint咨询师之路:备份和恢复系列三 - 备份web和服务应用程序
- CSDN问答频道“华章杯”7月排行榜活动开始,丰厚奖品等你拿
- 关于getchar函数缓冲区的问题
- Java 读书笔记 (十一) Number &; Math 类
- SQL优化 MySQL版 - 避免索引失效原则(二)
- javascript浏览器事件
- python列表的切片操作允许索引超出范围
- 第八周--Linux中进程调度与进程切换的过程
- 1129 Recommendation System