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

从父页面重定向 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

没有找到匹配的内容?试试慕课网站内搜索吧

添加回答

代码语言

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号