是否有方法禁止从electron中的`file://`协议提供的嵌套iframe访问`window.top`?

是否有方法禁止从electron中的`file://`协议提供的嵌套iframe访问`window.top`?,electron,cross-domain,content-security-policy,Electron,Cross Domain,Content Security Policy,例如: 电子主条目是file://main.html 嵌套的iframe条目是file://sub.html 在file://sub.htmlcontext可以访问window.topcontext的main.html,我知道原因是同源策略文件:// 在相同的文件://协议下,是否有禁止访问window.top的解决方案?window.top.location.href可从内部分配。如果您希望限制这种行为,请使用

例如:

  • 电子主条目是
    file://main.html
    • 嵌套的iframe条目是
      file://sub.html
file://sub.html
context可以访问
window.top
context的
main.html
,我知道原因是同源策略
文件://


在相同的
文件://
协议下,是否有禁止访问
window.top
的解决方案?

window.top.location.href
可从内部分配。如果您希望限制这种行为,请使用