为了账号安全,请及时绑定邮箱和手机立即绑定

从父页面重定向 iframe

从父页面重定向 iframe

慕婉清6462132 2024-01-11 17:30:19
我有一个疑问,如何从其父页面重定向 iframe?我有这个if(($mypassword == "home.guava")) {     echo "<script>window.top.location.href = \"teste\";</script>"; }在我附加到 iframe 页面的 php 文件中。但我需要的是这样的东西,它将从父页面重定向 iframe!谢谢大家:D
查看完整描述

1 回答

?
狐的传说

TA贡献1804条经验 获得超3个赞

如果脚本位于父级中,则不必遇到问题。


if(($mypassword == "home.guava")) {

    echo "<script>document.getElementsByTagName('iframe')[0].src = \"teste\";</script>";

}


例子:


<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;


查看完整回答
反对 回复 2024-01-11
  • 1 回答
  • 0 关注
  • 42 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信