var BrowserWindow = require('browser-window');
var win = new BrowserWindow({ width: 800, height: 600, show: false });
-win.on('destroyed', function() {
+win.on('closed', function() {
win = null;
});
Emitted when the document changed its title, calling `event.preventDefault()`
would prevent the native window's title to change.
-### Event: 'loading-state-changed'
-
-* `event` Event
-* `isLoading` Boolean
-
-Emitted when the window is starting or is done loading a page.
-
### Event: 'close'
* `event` Event
Emitted when the unresponsive web page becomes responsive again.
-### Event: 'crashed'
-
-Emitted when the renderer process is crashed.
-
### Event: 'blur'
Emiited when window loses focus.
Returns the window that is focused in this application.
-### Class Method: BrowserWindow.fromProcessIdAndRoutingId(processId, routingId)
+### Class Method: BrowserWindow.fromWebContents(webContents)
+
+* `webContents` WebContents
+
+Find a window according to the `webContents` it owns
-* `processId` Integer
-* `routingId` Integer
+### BrowserWindow.webContents
-Find a window according to its `processId` and `routingId`.
+The `WebContents` object this window owns, all web page related events and
+operations would be done via it.
+
+### BrowserWindow.devToolsWebContents
+
+Get the `WebContents` of devtools of this window.
### BrowserWindow.destroy()
Starts inspecting element at position (`x`, `y`).
-### BrowserWindow.executeJavaScriptInDevTools(code)
-
-* `code` String
-
-Evaluate `code` in devtools to use
-[InspectorFrontendAPI](https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/devtools/front_end/InspectorFrontendAPI.js&q=InspectorFrontendAPI&sq=package:chromium&type=cs)
-
### BrowserWindow.focusOnWebView()
### BrowserWindow.blurWebView()
[remote](../renderer/remote.md) if you are going to use this API in renderer
process.
-### BrowserWindow.getPageTitle()
-
-Returns the title of web page.
+### BrowserWindow.loadUrl(url)
-### BrowserWindow.isLoading()
+Same with `webContents.loadUrl(url)`.
-Returns whether web page is still loading resources.
+## Class: WebContents
-### BrowserWindow.isWaitingForResponse()
+A `WebContents` is responsible for rendering and controlling a web page.
-Returns whether web page is waiting for a first-response for the main resource
-of the page.
+`WebContents` is an
+[EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter).
-### BrowserWindow.stop()
+### Event: 'crashed'
-Stops any pending navigation.
+Emitted when the renderer process is crashed.
-### BrowserWindow.getProcessId()
+### Event: 'did-finish-load'
-Returns window's process ID. The process ID and routing ID can be used
-together to locate a window.
+Emitted when the navigation is done, i.e. the spinner of the tab will stop
+spinning, and the onload event was dispatched.
-### BrowserWindow.getRoutingId()
+### Event: 'did-start-loading'
-Returns window's routing ID. The process ID and routing ID can be used
-together to locate a window.
+### Event: 'did-stop-loading'
-### BrowserWindow.loadUrl(url)
+### WebContents.loadUrl(url)
* `url` URL
Loads the `url` in the window, the `url` must contains the protocol prefix,
e.g. the `http://` or `file://`.
-### BrowserWindow.getUrl()
+### WebContents.getUrl()
Returns URL of current web page.
-### BrowserWindow.canGoBack()
+### WebContents.getTitle()
+
+Returns the title of web page.
+
+### WebContents.isLoading()
+
+Returns whether web page is still loading resources.
+
+### WebContents.isWaitingForResponse()
+
+Returns whether web page is waiting for a first-response for the main resource
+of the page.
+
+### WebContents.stop()
+
+Stops any pending navigation.
+
+### WebContents.reload()
+
+Reloads current page.
+
+### WebContents.reloadIgnoringCache()
+
+Reloads current page and ignores cache.
+
+### WebContents.canGoBack()
Returns whether the web page can go back.
-### BrowserWindow.canGoForward()
+### WebContents.canGoForward()
Returns whether the web page can go forward.
-### BrowserWindow.canGoToOffset(offset)
+### WebContents.canGoToOffset(offset)
* `offset` Integer
Returns whether the web page can go to `offset`.
-### BrowserWindow.goBack()
+### WebContents.goBack()
Makes the web page go back.
-### BrowserWindow.goForward()
+### WebContents.goForward()
Makes the web page go forward.
-### BrowserWindow.goToIndex(index)
+### WebContents.goToIndex(index)
* `index` Integer
Navigates to the specified absolute index.
-### BrowserWindow.goToOffset(offset)
+### WebContents.goToOffset(offset)
* `offset` Integer
Navigates to the specified offset from the "current entry".
-### BrowserWindow.reload()
+### WebContents.IsCrashed()
+
+Whether the renderer process has crashed.
+
+### WebContents.executeJavaScript(code)
+
+* `code` String
+
+Evaluate `code` in page.
-Reloads current window.
+### WebContents.send(channel[, args...])
-### BrowserWindow.reloadIgnoringCache()
+* `channel` String
-Reloads current window and ignores cache.
+Send `args..` to the web page via `channel` in asynchronous message, the web
+page can handle it by listening to the `channel` event of `ipc` module.