简体   繁体   English

如何根据浏览器窗口宽度和文档长度自动调整iframe的大小?

[英]How to automatically resize an iframe based on browser window width and document length?

I need to create a frameborder=0 iframe with no scroll bars. 我需要创建一个没有滚动条的frameborder=0 iframe。

It needs to automatically resize its width based on the browser window's current width. 它需要根据浏览器窗口的当前宽度自动调整其宽度。

Its height needs to be based on the document.length . 它的高度必须基于document.length So if it's a long page, the iframe needs to stretch way down. 因此,如果页面较长,则iframe需要向下延伸。

This way, there is no scrollbar created in the iframe. 这样,在iframe中就不会创建滚动条。

var myIframe = $(document.frames['idIframe']);

$(document).bind('resize', function() {

   myIframe.attr("width", $(this).width());
   myIframe.attr("height", $(this).height());

});

这里的问题可能会为您提供答案。

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

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