window.open()详解
生活随笔
收集整理的這篇文章主要介紹了
window.open()详解
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
語法
window.open(URL,name,specs,replace) var specs="height=400,width=600,alwaysRaised,directories=no,toolbar=no,titlebar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no";返回值:
oNewWindow : 對象(Element)。返回對新的 window 對象的引用。
window.opener 實際上就是通過window.open打開的窗體的父窗體。
當彈出子窗口使用的是 window.open();
在子窗口調用父窗口的方法:
當彈出窗口使用的是模態窗口 window.showModelDialog();
在子窗口調用父窗口的方法:
子窗口給父窗口傳值的時候
window.parent.opener.document.getElementById("A431").value= “12345”;刷新父窗口并關閉當前窗口
function refreshParent() { window.opener.location.href = window.opener.location.href;//通常在使用window.opener的時候要去判斷父窗口的狀態,//如果父窗口被關閉或者更新,就會出錯,//解決辦法是加上如下的驗證if(window.opener && !window.opener.closed)if (window.opener.progressWindow) { window.opener.progressWindow.close(); } window.close(); }window.parent和window.opener的用法
1.window.parent----是iframe頁面調用父頁面對象
var parentWin=window.parent;parentWin.form.username.value="12345";2.window.opener----是window.open打開的子頁面對象調用父頁面對象
window.parent.opener.document.getElementById("A431").value= “12345”;總結
以上是生活随笔為你收集整理的window.open()详解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 分享几个病毒分析检测网址
- 下一篇: 最全的纯净系统下载地址