gpt4 book ai didi

javascript - 单击页面链接时重新调整站点的主体和 iframe

转载 作者:行者123 更新时间:2023-11-30 18:35:24 25 4
gpt4 key购买 nike

我有一个在其中加载页面的 iframe.. 当在 iframe 中的页面上单击链接时,调整父主体的大小,也就是具有 iframe 主体的文档..

 Body         <------------------------
Iframe |
Page |
Link... Upon Click, resize body --

我该怎么做?我试过 Parent.document.body.style.width = "200px"。它没有用。不知道该怎么办。请帮忙!

function Parentresize(id)
{
var newheight = 2000;
var newwidth = 2000;
parent.document.getElementById(id).height= (newheight) + "px";
parent.document.getElementById(id).width= (newwidth) + "px";
}

最佳答案

我认为您错过了 style.heightstyle.width

这是我在iframe中使用的代码

<script language="javascript">
function Parentresize(id)
{
alert("U r there");
var newheight = 200;
var newwidth = 200;
parent.document.getElementById(id).style.height = newheight + "px";
parent.document.getElementById(id).style.width = newwidth + "px";
}
</script>


<a href="javascript:Parentresize('sam');" >Call Me </a>

关于javascript - 单击页面链接时重新调整站点的主体和 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8352698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com