我需要使用什么JavaScript从iframe重定向父窗口?

我希望他们点击一个超链接,使用JavaScript或任何其他方法,将父窗口重定向到一个新的URL。


当前回答

window.top.location.href = "http://example.com";

窗口。Top指的是位于框架层次结构顶部的页面的窗口对象。

其他回答

这将解决痛苦。

<script>parent.location='http://google.com';</script>
window.top.location.href = "http://example.com";

窗口。Top指的是位于框架层次结构顶部的页面的窗口对象。

重定向父窗口中的iframe通过相同父窗口中的iframe:

window.parent.document.getElementById("content").src = "content.aspx?id=12";
window.top.location.href = "http://www.example.com"; 

将重定向最上面的父Iframe。

window.parent.location.href = "http://www.example.com"; 

将重定向父iframe。

对于当前页面- window.location.href = "你的url在这里";

对于父页面- window.top.location.href = "你的url在这里";

从HTML

<a href="http://someurl" target="_top">link</a>