父頁面與子頁面之間的操作以及對iframe的操作

2021-09-26 20:18:41 字數 304 閱讀 4128

在開發過程中,有時會遇到父頁面的內容需要在子頁面做更改,父頁面也同時能夠改變。那如何做到父頁面與子頁面的互動?

子頁面呼叫父頁面的方法:window.parent.方法;或window.opener.方法;

子頁面呼叫父頁面的變數:window.opener.變數名;或window.opener.變數

獲取iframe的物件:document.getelementbyid(iframeid).contentdocument

頁面關閉之前執行的方法:

window.onbeforeunload = function(){

iframe子頁面與父頁面之間互相操作的方法。

jquery取得iframe中元素的幾種方法 在iframe子頁面獲取父頁面元素 如下 objid parent.document 在父頁面 獲取iframe子頁面的元素 如下 objid document.frames iframename document document.getelement...

父頁面與子頁面之間傳值

size small 如果在頁面中不涉及到第三方的外掛程式 比如 artdialog 可以用如下的方式開啟子頁面 size window.open 子頁面中獲取父頁面物件 window.opener window.showmodaldialog 子頁面中獲取父頁面物件 window.dialogar...

iframe子頁面與父頁面之間通訊

父頁面parent.html function say function callchild script head iframe body html 子頁面child.html function say function callparent script head body html 方法呼叫 ...