javascript - 未捕获的安全错误 : Failed to read the 'contentDocument' property from 'HTMLIFrameElement'

标签 javascript jquery iframe

我正在尝试为特定需求制作我自己的“网站检查器”,但我在访问 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/

相关文章:

ajax - 身份验证 header 不发送 JQuery Ajax

javascript - 简单的 JQuery slider 无法正常工作

.htaccess - 如何使用 .htaccess 允许在我的 iframe 中访问页面而不是直接访问?

html - 表单 target=iframe 正在重定向而不是加载

javascript - 访问对象内部的关联数组

javascript - 在网格中显示组合框的值时出现问题

javascript - RegExp 提取特定字符串,后跟任何带有前导/尾随空格的数字

javascript - 提交后不要清除输入

Javascript onSubmit 函数自动执行

javascript - iframe 内的 AngularJS ng-src