单个Iframe适应
οnlοad="this.style.height=iframe1.document.body.scrollHeight"
自适应多级Iframe高度
- //进行Iframe的自动撑开,让所有父页面的Iframe都自动适应包含页高度
- function autoHeight(){
- var doc = document,
- p = window;
- while(p = p.parent){
- var frames = p.frames,
- frame,
- i = 0;
- while(frame = frames[i++]){
- if(frame.document == doc){
- frame.frameElement.style.height = doc.body.scrollHeight;
- doc = p.document;
- break;
- }
- }
- if(p == top){
- break;
- }
- }
- }