我正在尝试为特定需求制作我自己的“网站检查器”,但我在访问 iFrame 时遇到问题..
Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http:// checker.xcore.co.il" from accessing a frame with origin "http:// xcore.co.il". The frame requesting access set "document.domain" to "checker.xcore.co.il", but the frame being accessed did not. Both must set "document.domain" to the same value to allow access.
我必须使用 iFrame 执行此操作,因为我需要访问类 CSS。 Click on this link ,加载网站然后点击右侧的“fontSizeErrors” 然后您可以在控制台日志中看到错误。
请问我怎样才能通过这个??我在 Google 上找不到任何有用的信息..
谢谢!
最佳答案
这是所有浏览器使用的正常安全措施。您无法访问具有不同来源的元素或框架,这将是一个巨大的安全漏洞。因此,浏览器会阻止所有尝试执行此类操作的脚本。要在框架内执行任何操作,其内容必须具有相同的来源。
更多信息take look at this answer我的。
关于javascript - 未捕获的安全错误 : Failed to read the 'contentDocument' property from 'HTMLIFrameElement' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26329519/