javascript 由于端口、域和端口必须匹配的 iFrame 被阻止
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18793382/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iFrame blocked due to portocols, domains & ports must match
提问by JPN
I am getting the error below:
我收到以下错误:
Blocked a frame with origin
https://<my host ip>
from accessing a frame with originhttps://<target host ip>
. Protocols, domains, and ports must match.
阻止具有 origin
https://<my host ip>
的框架访问具有 origin 的框架https://<target host ip>
。协议、域和端口必须匹配。
If you notice both are 'https'. But still the error occurs. Please help - how do I avoid this.
如果您注意到两者都是“https”。但仍然发生错误。请帮助 - 我如何避免这种情况。
回答by epascarello
As the title says:
正如标题所说:
domains & ports must match
Two different ips, that means you have two different domains.
两个不同的ips,这意味着你有两个不同的域。
Read about the same origin policy
阅读同源政策
If you control both domains, you need to look into window.postMessage
如果您控制两个域,则需要查看 window.postMessage
回答by Bmoore
Protocols, domains, and ports must match
协议、域和端口必须匹配
<my host ip>
is not the same as <target host ip>
These are both parts of the domain in the url.
<my host ip>
不一样<target host ip>
这些都是 url 中域的部分。
http:// is the Protocol
ip or website name is the domain
:xxxx is the port
http:// 是协议
ip 或网站名称是域
:xxxx 是端口
so end result: http://ip:xxxx
所以最终结果: http://ip:xxxx