午夜国产狂喷潮在线观看|国产AⅤ精品一区二区久久|中文字幕AV中文字幕|国产看片高清在线

    window.parent與window.opener的區(qū)別與使用
    來源:易賢網(wǎng) 閱讀:1062 次 日期:2015-04-21 09:59:09
    溫馨提示:易賢網(wǎng)小編為您整理了“window.parent與window.opener的區(qū)別與使用”,方便廣大網(wǎng)友查閱!

    1、window.parent 是iframe頁面調(diào)用父頁面對象

    舉例: a.html

    <html>

    <head><title>A</title></head>

    <body>

    <form name=”form1″ id=”form1″>

    <input type=”text” name=”username” id=”username”/>

    </form>

    <iframe src=”b.html” width=100%></iframe>

    </body>

    </html>

    如果我們需要在b.html中要對a.html中的username文本框賦值(就如很多上傳功能,上傳功能頁在ifrmae中,上傳成功后把上傳后的路徑放入父頁面的文本框中),我們應該在b.html中寫:

    <script type=”text/javascript”>

    var _parentWin = window.parent;

    _parentWin.form1.username.value = “xxxx”;

    </script>

    2、window.opener 是 window.open 打開的子頁面調(diào)用父頁面對象

    opener:對打開當前窗口的window對象的引用,如果當前窗口被用戶打開,則它的值為null。

    self代表自身窗口,opener代表打開自身的那個窗口,比如窗口a.html打開窗口b.html。如果靠window.open方法,則對于窗口b.html,self代表b.html自己,而opener代表窗口a.html。

    舉例:a.html

    <input type=”text” name=”username” id=”username”/>

    <a onclick=”window.open(this.href,”,’resizable=yes,width=800,height=600,status’); return false” href=”b.html”>B</a>

    如果需要在b.html中對a.html中的表單元素賦值,我們應該在b.html中這么寫

    <a href=”javascript:try{window.opener.document.getElementById(‘username’).contentWindow.

    frames[0].document.getElementsByTagName(‘body’)[0].innerHTML+=’xxx‘}catch(e){};window.close();“>插入</a>

    在后面用window.close關(guān)閉b.html。WindsPhoto 2.7.3 中在文章編輯頁面彈出新窗口(圖片列表)后,選擇插入已上傳圖片便是如此實現(xiàn)的。

    更多信息請查看IT技術(shù)專欄

    更多信息請查看腳本欄目
    易賢網(wǎng)手機網(wǎng)站地址:window.parent與window.opener的區(qū)別與使用

    2025國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)