当源来自外部服务器时获取 Iframe innerHTML

Get Iframe innerHTML when source is from foreign serwer

我有简单的 iframe,我想获取 iframe innerHTML。 但是当源来自外部服务器时它不起作用

您无法访问跨源页面。仅当 src 为 about:blank 或应用 同源策略 时,才能访问 iframe 和子 windows。

两个 windows 之间唯一允许和支持的通信方法是:window.postMessage() and the window: Message-Event,它提供了一种易于使用的 API 通信方式。