iframe父視窗和子視窗之間的呼叫

2021-09-06 13:03:19 字數 781 閱讀 8309

1>父視窗獲取子視窗

js方法

document.getelementbyid('if1').contentwindow.document;

window.frames["if1"].document.body;

jquery方法

$(this).contents();

2>父視窗獲取子視窗高度

js方法

document.getelementbyid('if1').contentwindow.document.body.scrollheight;

window.frames["if1"].document.body.scrollheight;

jquery方法

$(this).contents()[0].body.scrollheight;

3>子視窗呼叫父視窗方法

js方法

window.parent.fun();

4>iframe自適應高度

在iframe的load事件中重新設定iframe的高度。

$(function () );

});});

程式設計師的基礎教程:菜鳥程式設計師

iframe 父視窗和子視窗的呼叫方法

父視窗呼叫子視窗 iframe id.iframe document object.object attribute attribute value 例子 onclick iframe text.myh1.innertext 子視窗呼叫父視窗 parent.parent document objec...

iframe 父視窗和子視窗的呼叫方法

父視窗呼叫子視窗 iframe id.iframe document object.object attribute attribute value 例子 onclick iframe text.myh1.innertext http www.pint.com 子視窗呼叫父視窗 parent.par...

iframe 父視窗和子視窗的呼叫方法

父視窗呼叫子視窗 iframe id.iframe document object.object attribute attribute value 例子 onclick iframe text.myh1.innertext 子視窗呼叫父視窗 parent.parent document objec...