//放在子页 var GLOB_CONST_extraHeight_IE = 4; //using default value 4 of IE var GLOB_CONST_extraHeight_NOIE = 16 ; //using default value 16 of FF function autosize() { try { var iframe = parent.document.getElementsByTagName('iframe'); var len = iframe.length; if (len <= 0) { return; } var i; if (iframe[0].contentDocument) { //for mozilla, firefox for (i = 0; i < len; i ++) { if (iframe[i].contentDocument == document) { iframe[i].style.height=document.body.offsetHeight + GLOB_CONST_extraHeight_NOIE; return; } } } else { // for IE iframe = parent.document.frames; len = iframe.length; if (len <= 0) { return; } for (i = 0; i < len; i ++) { if (iframe[i].document == document) { iframe[i].frameElement.style.height=document.body.scrollHeight + GLOB_CONST_extraHeight_IE; return; } } } }catch(err) { alert(err.message); } }