我试图从 iFrame 访问父窗口的 URL,但我的服务器出现错误:
Unsafe JavaScript attempt to access frame with URL http://www.domain.com/folder/ from frame with URL http://www.domain.com/folder/file.html. The frame being accessed set 'document.domain' to 'domain.com', but the frame requesting access did not. Both must set 'document.domain' to the same value to allow access.
我在同一个域中,所以我不明白为什么会出现此错误。 供您引用,在本地主机上一切正常。
感谢您的帮助。
最佳答案
好的,我找到了解决方案。 我输入了这段代码并且有效:
document.domain = 'domain.com';
关于javascript - 不安全的 JavaScript 尝试使用 URL 访问框架 - 在同一域中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14592685/