我有一个包含 2 个 iframe 标签的页面:
<iframe src="top.html" seamless="seamless" width=100% height=100% id="up" name="up" frameborder="0"></iframe>
<iframe src="main.html" seamless="seamless" width=100% height=800px id="main" frameborder="0"></iframe>
在 main.html 中我有以下代码:
parent.frames['up'].location.href = "top.html";
想法是刷新“up”iframe。 有时它工作,有时什么也没有发生,有时我得到一个异常:
Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.
我做错了什么?
最佳答案
试试下面的代码:
parent.frames["up"].location.replace("top.html")
关于javascript - 更改一个 iframe 的 url 从另一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20622571/