Window.get([window_object])
用途:获取指定window_object窗口(未指定时默认为当前窗口)的窗口对象
window_object
{DOM Window}
(可选) DOM窗口对象- Returns
{Window}
the nativeWindow
object
如果 window_object
是 iframe
, 该方法将返回其顶层窗口的 Window
对象.
- // 获取当前窗口的`Window`对象
- var win = nw.Window.get();
- /获取iframe的窗口
- var iframeWin = nw.Window.get(iframe.contentWindow);
- //返回true
- console.log(iframeWin === win);
- // 创建窗口并获取它的窗口对象
- nw.Window.open('https://github.com/nwjs/nw.js', {}, function(new_win) {
- // do something with the newly created window
- });