iframe自适应子页面高度

来源:互联网 发布:查看数据库字符集 编辑:程序博客网 时间:2024/05/19 12:16
方式112345//注意:下面的代码是放在和iframe同一个页面中调用$("#iframeId").load(function () {    var mainheight = $(this).contents().find("body").height() + 30;    $(this).height(mainheight);});方式2123456//注意:下面的代码是放在iframe引用的子页面中调用$(window.parent.document).find("#iframeId").load(function () {    var main = $(window.parent.document).find("#iframeId");    var thisheight = $(document).height() + 30;    main.height(thisheight);});
0 0
原创粉丝点击