[英]Redirect iframe from parent page
I have a doubt, how can I redirect an iframe from his parent page?我有疑问,如何从他的父页面重定向 iframe? I have this
我有这个
if(($mypassword == "home.guava")) {
echo "<script>window.top.location.href = \"teste\";</script>";
}
in my php file that is attached to the iframe page.在我的 php 文件中,该文件附加到 iframe 页面。 But what I need is something like this that will redirect the iframe from the parent page!
但我需要的是这样的东西,它将从父页面重定向 iframe!
Thanks to you all:D谢谢大家:D
If the script is in the parent you don't have to have problems.如果脚本在父级中,则不必有问题。
if(($mypassword == "home.guava")) {
echo "<script>document.getElementsByTagName('iframe')[0].src = \"teste\";</script>";
}
Examples:例子:
<body>
<iframe id="one" src="url"></iframe>
<iframe id="two" src="url"></iframe>
</body>
// Parent to child:
document.getElementsById('one').src = url;
// Child to parent
window.parent.location.href = url;
// Child to other child
window.parent.document.getElementById('two').src = url;
// Current (Child or Parent)
window.location.href = url;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.