document.domain 的 Chrome 解决方案
由于某种原因,chrome 不再支持 document.domain,并且在包含子域的 iframe 和包含 iframe 的子域中读取该行时会发出错误。这附近还有吗?
错误:未捕获错误:SECURITY_ERR:DOM 异常 18
For some reason chrome doesn't support document.domain any more and spits out an error when the line is read in the iframe containing a subdomain and the subdomain containing the iframe. Is there anyway around this?
Error: Uncaught Error: SECURITY_ERR: DOM Exception 18
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文档域应小写,规则如下:
Document domain should be lowercase and the rules are like this:
只要您位于同一域中,
document.domain
就应该适用于 iframe:如果您尝试访问与父框架位于不同域的 iframe 文档,您将获取您所看到的安全错误。
请注意,子域也被视为不同的域,因此您将遇到跨域问题: 一个关于跨域(子域)ajax请求的问题
document.domain
should work for iframes as long as you're on the same domain:If you're trying to access the document of an iframe that's on a different domain than the parent frame, you'll get the security error you're seeing.
Note that subdomains are considered different domains too, so you'll run into cross domain issues: A question about cross-domain (subdomain) ajax request