简体   繁体   English

iframe高度是否不会使用“ onresize =”方法调整大小?

[英]Iframe height will not resize with method “onresize=”?

I have an iframe and its height will automatically be worked out, But when I resize the screen the height is not updating itself to match the iframes content height here is my work can someone point out where I am going wrong? 我有一个iframe,它的高度会自动计算出来,但是当我调整屏幕大小时,高度不会自动更新以匹配iframe内容的高度,这是我的工作,有人可以指出我要去哪里了吗?

Js s

 function resizeIframe(obj) {
    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
  }

iframe iframe

<body>

<iframe name="Stack" src="index.html" frameborder="0" width="100%" scrolling="no" id="iframe" onload="resizeIframe(this);" onresize="resizeIframe(this);"/>

</body>

Im using onresize on the iframe to try and make the resizeIframe function "play" again when the iframe/window is resized but its not working I also tried onresize on the body tag still nothing Please can someone point me in the right direction, Thank you in advance. 我在iframe上使用onresize尝试使iframe /窗口调整大小后再次使resizeIframe函数“播放”,但无法正常工作我也尝试在body标签上使用onresize仍然一无所获请有人可以向我指出正确的方向,谢谢提前。

您需要从iframe的父文档中调用resize()处理函数:

$('iframe').resize(function() {} );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM