直接分享代码:
<script>
$(function () {
resizeIframe();
$(window).resize(function () {
resizeIframe();
});
});
//调整iframe尺寸的方法
function resizeIframe() {
var expectWidth = $(document).width() * 0.9; //总宽度为屏幕宽度的0.9倍
$("iframe").each(function () {
expectWidth = $(this).parent().width();
$(this).height(expectWidth * $(this).height() / $(this).width());
$(this).width(expectWidth);
});
}
</script>
也是网上搜索到的,自己留个记录。