Skip to content

Compare: Window

New page
44 changes: 43 additions & 1 deletion Window.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ _Window API requires node-webkit >= v0.3.0_

`Window` is a wrapper of DOM's `window` object, it has extended operations and can receive various window events.

You can not create a new `Window`, you can only get a `Window` object by using `Window.get()`. Every `Window` is an instance of [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter) object, and you're able to use `Window.on(...)` to response to native window's events.
Every `Window` is an instance of [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter) object, and you're able to use `Window.on(...)` to response to native window's events.

## Synopsis

Expand Down Expand Up @@ -51,6 +51,22 @@ var new_win = gui.Window.get(
);
```
### open(url[, options])
Open a new window and load `url` in it, you can specify extra `options` with the window. All window subfields in [[Manifest format]] can be used.
```javascript
var win = gui.Window.open('https://github.com', {
position: 'center',
width: 901,
height: 127
});
```
### Window.window
**Get** DOM's `window` object in the native window.
### Window.x/Window.y
**Get** or **Set** left/top offset from window to screen.
Expand Down Expand Up @@ -125,6 +141,18 @@ win.on('close', function() {
win.close();
```
### Window.reload()
_Requires node-webkit >= v0.3.5_
Reloads the current window.
### Window.reloadIgnoringCache()
_Requires node-webkit >= v0.3.5_
Like reload(), but don't use caches (aka "shift-reload").
### Window.maximize()
Maximize the window on GTK and Windows, zoom the window on Mac.
Expand Down Expand Up @@ -250,6 +278,20 @@ The `closed` event is emitted **after** corresponding window is closed. Normally
</script>
```
### loading
_Requires node-webkit >= v0.3.5_
Emitted when the window starts to reload, normally you cannot catch this event because usually it's emitted before you actually setup the callback.
The only situation that you can catch this event is when you refresh the window and listen to this event in another window.
### loaded
_Requires node-webkit >= v0.3.5_
Emitted when the window is fully loaded, this event behaves the same with `window.onload`, but doesn't rely on the DOM.
### focus
Emitted when window gets focus.
Expand Down