javascript 如何将 URL 重定向到父 iframe

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14985048/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 23:04:19  来源:igfitidea点击:

How to redirect an URL to a parent iframe

phpjavascript

提问by Mollo

Im trying to redirect an user of my page when I ban him from my chat box using this (php):

当我使用这个 (php) 禁止他进入我的聊天框时,我试图重定向我页面的用户:

header("location: index.php");
exit;

The problem is the index.phppage is opening inside the connected users section, in this case inside a div. How can i redirect the user's main page ?

问题是index.php页面在已连接的用户部分中打开,在这种情况下是在div. 如何重定向用户的主页?

Thanks for your time.

谢谢你的时间。

回答by Afghan Dev

Try this in the javascript code:

在 javascript 代码中试试这个:

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

回答by Mollo

This is the answer using javascript:

这是使用javascript的答案:

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