The BrowserWindow
class gives you the ability to create a browser window. For
example:
// In the main process.
const BrowserWindow = require('electro').BrowserWindow;
var win = new BrowserWindow({ width: 800, height: 600, show: false });
win.on('closed', function() {
win = null;
});
win.loadURL('https://nodekit.io');
win.show();
BrowserWindow
is an
EventEmitter.
It creates a new BrowserWindow
with native properties as set by the options
.
options
Objectwidth
Integer - Window's width in pixels. Default is800
.height
Integer - Window's height in pixels. Default is600
.title
String - Default window title. Default is"Electron"
.backgroundColor
String - Window's background color as Hexadecimal value, like#66CD00
or#FFF
or#80FFFFFF
(alpha is supported). Default is#000
(black) for Linux and Windows,#FFF
for Mac (or clear if transparent).
The BrowserWindow
object emits the following events:
Emitted when the navigation is done, i.e. the spinner of the tab has stopped
spinning, and the onload
event was dispatched.
This event emitted when the load failed or was cancelled.
The BrowserWindow
object has the following methods:
Returns an array of all opened browser windows.
Returns the window that is focused in this application, otherwise returns null
.
webContents
WebContents
Find a window according to the webContents
it owns.
id
Integer
Find a window according to its ID.
Objects created with new BrowserWindow
have the following properties:
// In this example `win` is our instance
var win = new BrowserWindow({ width: 800, height: 600 });
The WebContents
object this window owns, all web page related events and
operations will be done via it.
See the webContents
documentation for its methods and
events.
The unique ID of this window.
Objects created with new BrowserWindow
have the following instance methods:
Try to close the window, this has the same effect with user manually clicking the close button of the window.
Same as webContents.loadURL(url[, options])
.
Same as webContents.reload
.
Shows and gives focus to the window.
Hides the window.