简体   繁体   English

iframe调整大小无法使用srcdoc html调整iframe的大小

[英]iframe-resizer not resize iframe with srcdoc html

I want to resize an the height of an iframe using html from srcdoc and I choosed to use the iframe-resizer library. 我想使用srcdoc中的html来调整iframe的高度,因此我选择使用iframe-resizer库。 But the iframe is never resizing and callbacks are never called. 但是iframe永远不会调整大小,也永远不会调用回调。

Html : HTML:

<iframe scrolling="no" class="preview-iframe" id="iframe3" srcdoc="<html><head></head><body><p>TEST</p>
</body></html>"></iframe>

JS : JS:

$('iframe#iframe3').iFrameResize({
  heightCalculationMethod: 'bodyScroll',
  log: true,
  resizedCallback: function () {
    console.log('resize');
  },
  initCallback: function () {
    console.log('init');
  },
});

Here is my jsfiddle 这是我的jsfiddle

您的srcdoc需要具有指向iframeResizer.contentWindow.js文件的链接。

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

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