从父页面重定向 iframe

我有一个疑问,如何从其父页面重定向 iframe?我有这个

if(($mypassword == "home.guava")) {
    echo "<script>window.top.location.href = \"teste\";</script>";
}

在我附加到 iframe 页面的 php 文件中。但我需要的是这样的东西,它将从父页面重定向 iframe!

谢谢大家:D


慕婉清6462132
浏览 51回答 1
1回答

狐的传说

如果脚本位于父级中,则不必遇到问题。if(($mypassword == "home.guava")) {&nbsp; &nbsp; echo "<script>document.getElementsByTagName('iframe')[0].src = \"teste\";</script>";}例子:<body>&nbsp; <iframe id="one" src="url"></iframe>&nbsp; <iframe id="two" src="url"></iframe></body>// Parent to child:document.getElementsById('one').src = url;// Child to parentwindow.parent.location.href = url;// Child to other childwindow.parent.document.getElementById('two').src = url;// Current (Child or Parent)window.location.href = url;
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5