所以我有一栏里面有这段代码:
<div class="cat">
<iframe src="sidebar.html" frameborder="0" ></iframe>
</div>
这是“ sidebar.html”中的一行:
<th target="_top" onclick="window.location='http://example.com'">example</th>
(请记住,这是表的一部分)
当我点击“示例”一词时,它实际上会重定向到应该显示的位置,但这仅在iframe内可见
我想将整个页面重定向到www.example.com
答案 0 :(得分:0)
只需添加“父母”即可。在window.location之前:
<th target="_top" onclick="parent.window.location='http://example.com'">example</th>
答案 1 :(得分:0)
您可以使用
window.top.location.href = "http://www.newurl.com";
更改父页面的URL。
简单的重定向仅在iframe中有效。