iframe自适应浏览器大小

来源:互联网 发布:linux远程连接的软件 编辑:程序博客网 时间:2024/05/10 00:40
//1.首先需要设置iframe默认大小<pre name="code" class="javascript">var height = $(document).height()-120;//120为top+bottom的高度.
$("#sys_main_iframe").attr("height",height+"px")
//2.改变页面大小时调用
$(window).resize(function() { var width = $(this).width(); var height = $(this).height(); console.log(width); console.log(height); height = height-120;//120为top+bottom的高度. console.log(height); $("#sys_main_iframe").attr("height",height+"px")});


0 0