我需要使用什么JavaScript从iframe重定向父窗口?
我希望他们点击一个超链接,使用JavaScript或任何其他方法,将父窗口重定向到一个新的URL。
我需要使用什么JavaScript从iframe重定向父窗口?
我希望他们点击一个超链接,使用JavaScript或任何其他方法,将父窗口重定向到一个新的URL。
当前回答
或者另一种选择如下(使用文档对象)
parent.document.location.href = "http://example.com";
其他回答
我发现<a href="…" target="_top">link</a>也能工作
window.top.location.href = 'index.html';
这将重定向主窗口到索引页。 谢谢
window.top.location.href = "http://www.example.com";
将重定向最上面的父Iframe。
window.parent.location.href = "http://www.example.com";
将重定向父iframe。
或者另一种选择如下(使用文档对象)
parent.document.location.href = "http://example.com";
这将解决痛苦。
<script>parent.location='http://google.com';</script>