我知道有很多类似的问题,唯一的区别是我在同一个域名下为两个页面提供服务时遇到了此问题。以下示例中可以看到这一点。
Uncaught DOMException: Blocked a frame with origin "https://content.samba.net" from accessing a cross-origin frame.
at findAPI (https://content.samba.net/00/07/19-10/scorm_support/scorm_support.js:14:10)
at getAPI (https://content.samba.net/00/07/19-10/scorm_support/scorm_support.js:61:13)
at https://content.samba.net/00/07/19-10/SCORM.htm:200:16
这不应该只发生在不同的域之间吗?
============================== 编辑 =======================================
当然,我发布文章几秒钟后就找到了问题所在。 SCORM软件包有一个定位SCORM API的函数。它查看顶部和打开程序。在我的情况下,Window Opener在不同的域中,正在尝试访问它。
我会留下来供历史记录。我的回答有详细信息。
sandbox
属性,请尝试将allow-same-origin
添加到值中。原因是,如果不包括allow-same-origin
,浏览器会将iframe的来源设置为null,并且从https://content.samba.net
到null来源的请求是跨源请求。请参阅https://dev59.com/1qLia4cB1Zd3GeqPquoB#44765536和https://dev59.com/KE0GtIcB2Jgan1znypVz#xRDsnYgBc1ULPQZFMzIk的答案,如果您需要更多详细信息,请参见https://dev59.com/31gQ5IYBdhLWcg3wxGzs#42242802。 - sideshowbarker