当我让本地 html 在 Chrome 的 iFrame (frame.src=) 中加载另一个本地 html 文件时,我无法通过 contentWindow 或 contentDocument 访问它的文档(即使 contentWindow 是文档本身的验证)因为它似乎当涉及本地 html 文件时,Chrome 不允许这样做。此功能是否可能会在下一版本的 Chrome 中发生变化?注意:它适用于(contentDocument 或 contentWindow)Safari 和 Opera、IE、WebKit。这似乎是一个安全问题,但 contentDocument 和 contentWindow 来自 W3C。
最佳答案
这是因为 Chrome 的限制,即同源策略。默认情况下,本地文件被认为属于不同的来源,不允许从另一个访问。要解决此问题,您可以使用 --allow-file-access-from-files
命令行开关启动 Chrome 应用程序。
关于html - 当 iFrame 从本地 html 文件加载本地 html 文件时,Chrome 的 future 版本是否可能支持 contentWindow/contentDocument?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10415759/