【问题标题】:CORS error when trying to scroll in a PDF iframe Electron [duplicate]尝试在 PDF iframe Electron 中滚动时出现 CORS 错误 [重复]
【发布时间】:2021-08-11 02:53:14
【问题描述】:

如何在 iframe 中读取和更改 PDF 的 x/y 坐标,我的 iframe 如下所示:<iframe id="pdf-interface" class="pdf-interface" src=path></iframe> 其中path 是 PDF 文件的本地路径。
到目前为止,我尝试的所有尝试都失败并显示错误消息:Uncaught DOMException: Blocked a frame with origin "http://127.0.0.1:8080" from accessing a cross-origin frame
有什么办法可以解决这个问题或有其他方法吗?

【问题讨论】:

  • 从您的本地主机提供 pdf,以便来源相同
  • 感谢您的帮助,我会查看资源,应该使用stackoverflow搜索引擎而不仅仅是google

标签: javascript html iframe electron cross-domain


【解决方案1】:

您不能直接访问跨域 iframe。

在 Quentin 的回答 https://stackoverflow.com/a/66139466/7942242 上阅读更多相关信息

Willy Wonka 的回答可能也会让您感兴趣https://stackoverflow.com/a/39685594/7942242,其中提供了有关如何绕过同源策略的参考。

【讨论】:

  • 我会调查一下,遗憾的是没有办法至少读出 pdf 的页码,这使得我认为 PDF 的 iframe 有点没用
猜你喜欢
  • 2012-10-03
  • 1970-01-01
  • 1970-01-01
  • 2020-08-03
  • 2021-12-26
  • 2021-11-11
  • 2021-10-30
  • 1970-01-01
  • 2021-08-10
相关资源
最近更新 更多