2007年4月10日 星期二

[javascript]Iframe與parentWindow

在網頁中有時侯會用到Iframe來嵌入另一個page
例如在"A網頁"中插入一個來源為"B網頁"的iframe

如果要在B網頁中去呼叫或使用A網頁的網頁控制項時
可以試著參考使用下例的語法

window.document.parentWindow.parent.document.getElementById("btnGO").click();

parentWindow:Retrieves a reference to the container object of the window(取得B網頁的reference)
parent:A網頁(B網頁的來源)

如此一來就可以在B網頁中呼叫A網頁btnGO按鈕的click事件了。

出處

【下列文章您可能也有興趣】

沒有留言: