超碰人人人人人,色婷婷综合久久久久中文一区二区,国产-第1页-浮力影院,欧美老妇另类久久久久久

LOGO OA教程 ERP教程 模切知識(shí)交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
版主

    window.opener與window.parent的區(qū)別

    tercel
    2010年8月6日 10:24 本文熱度 5417
    [p] 我們?nèi)绻玫絠frame的值傳到另一框架就要用到window.opener.document.getelementbyid(name).value = uvalue;這種形式哦。 [br]window.parent能獲取一個(gè)框架的父窗口或父框架。頂層窗口的parent引用的是它本身。 [br][br]可以用這一點(diǎn)特性來判斷這個(gè)窗口是否是頂層窗口。如: [br][br]code [br]function istopwindow( win ) [br]{ [br] if( win.parent == win ) return true; [br] else return false; [br]} [br]window.opener引用的是window.open打開的頁面的父頁面。 [br][br][br]opener即誰打開我的,比如a頁面利用window.open彈出了b頁面窗口,那么a頁面所在窗口就是b頁面的opener,在b頁面通過opener對(duì)象可以訪問a頁面。 [br]parent表示父窗口,比如一個(gè)a頁面利用iframe或frame調(diào)用b頁面,那么a頁面所在窗口就是b頁面的parent。 [br]在js中,window.opener只是對(duì)彈出窗口的母窗口的一個(gè)引用。比如: [br][br]a.html中,通過點(diǎn)擊按鈕等方式window.open出一個(gè)新的窗口b.html。那么在b.html中,就可以通過 window.opener(省略寫為opener)來引用a.html,包括a.html的document等對(duì)象,操作a.html的內(nèi)容。假如這個(gè)引用失敗,那么將返回null。所以在調(diào)用opener的對(duì)象前,要先判斷對(duì)象是否為null,否則會(huì)出現(xiàn)“對(duì)象為空或者不存在”的js錯(cuò)誤。 [br][br]window.opener 返回的是創(chuàng)建當(dāng)前窗口的那個(gè)窗口的引用,比如點(diǎn)擊了a.htm上的一個(gè)鏈接而打開了b.htm,然后我們打算在b.htm上輸入一個(gè)值然后賦予a.htm上的一個(gè)id為“name”的textbox中,就可以寫為: [br]window.opener.document.getelementbyid("name").value = "輸入的數(shù)據(jù)"; [br][br][br][br][br]====================================================================== [br][br][br][br]window.parent.location.reload() [br]讓打開這個(gè)窗口的父窗口刷新,然后本子窗口關(guān)閉! [br][br]window.parent.hidethisdiv() [br]應(yīng)該是讓打開這個(gè)窗口的父窗口的某個(gè)div影藏 [br][br]javascript:history.back() [br]就是后退啊!和瀏覽器里面的后退按鈕一樣!javascript:history.back(-1)就是后退一頁 [br][br][br][br]========================================= [br][br][br][br]前邊用window.opener=null來完成了窗口的無提示自動(dòng)關(guān)閉.簡單查了一下,window.opener是js中window的一個(gè)屬性,它返回的是打開當(dāng)前窗口的窗口對(duì)象.如果窗口a彈出一個(gè)窗口b,那么在b中window.opener就是窗口對(duì)象a. [br]這是javascript參考手冊(cè)里對(duì)于opener的描述 [br][br][br] when a source document opens a destination window by calling the open method, the opener property specifies the window of the source document. evaluate the opener property from the destination window. [br] this property persists across document unload in the opened window. [br] you can change the opener property at any time. [br] you may use window.open to open a new window and then use window.open on that window to open another window,and so on. in this way, you can end up with a chain of opened windows, each of which has an opener property pointing to the window that opened it. [br] communicator allows a maximum of 100 windows to be around at once.if you open window2 from window1 and then are done with window1, be sure to set the opener property of window2 to null. this allows javascript to garbage collect window1. if you do not set the opener property to null, the window1 object remains, even though it's no longer really needed. [br][br]我大概翻譯一下 [br]當(dāng)一個(gè)窗口用open方法打開了一個(gè)新窗口的時(shí)候,opener屬性就生效了,直到被打開的窗口關(guān)閉時(shí)失效. [br]你可以通過opener在被打開的窗口中對(duì)父窗口進(jìn)行一系列操作. [br]你可以在一個(gè)窗口中打開一個(gè)新窗口,新窗口又打開另外一個(gè)新窗口,新窗口又打開另外一個(gè)新窗口.....最后得到的是一串新窗口:em215:,然而每一個(gè)窗口的opener屬性都指向打開它的那個(gè)窗口. [br]設(shè)計(jì)者最多允許打開100個(gè)這樣的窗口.當(dāng)你通過open打開了一個(gè)新窗口后,確保在新窗口中將opener屬性設(shè)置為null(空).如果不這樣的話,會(huì)使瀏覽器持續(xù)的保留每個(gè)opener的值,直至資源耗盡. [br][br]js參考手冊(cè)還給出了幾個(gè)例子,我把我理解的部分演示一下~ [br][br]首先建立1.htm,它用open方法打開2.htm,代碼如下 [br][br][br]
    Copyright 2010-2025 ClickSun All Rights Reserved

  1. <source id="gl5kq"></source>