作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 iframe 中嵌入了一些 swf,但只有当页面刷新时,iframe 才会调整大小,然后如果我选择其他一个,那么不仅会显示动画,还会显示背景的所有 swf。这就是我正在使用的
if ( 'resizeIframe' === $('#onPlayAction').val() ) {
var ifrEl = $('div.player-container iframe.page-iframe')[0];
$(ifrEl).show();
ifrEl.src = htmlPageBrowserUri;
ifrEl.onload = function() {
ifrEl.width = ifrEl.contentWindow.document.body.scrollWidth;
ifrEl.height = ifrEl.contentWindow.document.body.scrollHeight;
}
}
最佳答案
有三种方法可以做到这一点。
$(window).on('resize', function (){
ifrEl.width = ... ;
ifrEl.height = ... ;
})
您可以使用一些 jQuery 插件,例如 iFrame Resizer
您可以使用一些漂亮的 CSS 技巧。去搜索responsive iframes using css
,你会找到很多好的答案。
希望这一切对您有所帮助。
关于javascript - 如何在不刷新页面的情况下调整 iframe 的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30998205/
我是一名优秀的程序员,十分优秀!