iframe页面布局、菜单、自定义高度
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
function reinitIframe(iframe){ var bHeight = iframe.contentWindow.document.body.scrollHeight; var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; //var blankHeight = iframe.contentDocument.body.scrollHeight; var height = Math.max(bHeight, dHeight); try{ iframe.height = bHeight; //iframe.height = blankHeight; //适应内部页面的大小 }catch (ex){ alert(ex+">>>>>>>>>>>>>>error0000"); } }
function reinitIframe(iframe){var win=iframe;var minheight = 200;if (document.getElementById){if (win && !window.opera){if (win.contentDocument && win.contentDocument.body.offsetHeight) win.height = win.contentDocument.body.offsetHeight; else if(win.Document && win.Document.body.scrollHeight) if(minheight<win.Document.body.scrollHeight){win.height = win.Document.body.scrollHeight;}else{win.height =minheight;}}}}
?
这样问题就解决了。
?
3、用了iframe之后,每次刷新页面都会跳转到首页,要是只刷新iframe就好了,于是写了下面的方法:
var check=function(e){ e=e||window.event; if((e.which||e.keyCode)==116){ if(e.preventDefault){ e.preventDefault(); window.frames["mainFrame"].location.reload(); } else{ event.keyCode = 0; e.returnValue=false; window.frames["mainFrame"].location.reload(); } } } if(document.addEventListener){ document.addEventListener("keydown",check,false); } else{ document.attachEvent("onkeydown",check); } ;
window.parent.document.mainFrame.user()//mainFrame父页面的iframe名称,user()父页面的方法
window.frames[i].location.href=url//i表示第几个iframe
?
?