本文實例講述了jQuery簡單實現iframe的高度根據頁面內容自適應的方法。分享給大家供大家參考,具體如下:
方式1:
//注意:下面的代碼是放在和iframe同一個頁面中調用$("#iframeId").load(function () { var mainheight = $(this).contents().find("body").height() + 30; $(this).height(mainheight);});
方式2:
//注意:下面的代碼是放在iframe引用的子頁面中調用$(window.parent.document).find("#iframeId").load(function () { var main = $(window.parent.document).find("#iframeId"); var thisheight = $(document).height() + 30; main.height(thisheight);});
更多關于jQuery相關內容感興趣的讀者可查看本站專題:《jQuery操作iframe技巧總結》、《jQuery擴展技巧總結》、《jQuery常用插件及用法總結》、《jQuery拖拽特效與技巧總結》、《jQuery表格(table)操作技巧匯總》、《jquery中Ajax用法總結》、《jQuery常見經典特效匯總》、《jQuery動畫與特效用法總結》及《jquery選擇器用法總結》
希望本文所述對大家jQuery程序設計有所幫助。
新聞熱點
疑難解答