<< return Browser Window Options in Electron application
There are many options when creating a BrowserWindow instance. Here are some of the most common and useful ones:
- Dimensions and Appearance:
- • width: Width of the window in pixels.
- • height: Height of the window in pixels.
- • minWidth: Minimum width.
- • minHeight: Minimum height.
- • maxWidth: Maximum width.
- • maxHeight: Maximum height.
- • x: Horizontal position of the window.
- • y: Vertical position of the window.
- • resizable: Whether the window can be resized (default: true).
- • movable: Whether the window can be moved (default: true).
- • minimizable: Whether the window can be minimized (default: true).
- • maximizable: Whether the window can be maximized (default: true).
- • closable: Whether the window can be closed (default: true).
- • alwaysOnTop: Whether the window should always stay on top of other windows.
- • fullscreen: Start the window in fullscreen mode.
- • fullscreenable: Whether the window can enter fullscreen mode (default: true).
- • skipTaskbar: Whether to show the window in the taskbar.
- • frame: Whether to include the window frame (default: true). Set to false for a frameless window.
- • titleBarStyle: Style of the title bar ('default', 'hidden', 'hiddenInset', 'customButtonsOnHover').
- • transparent: Makes the window background transparent.
- • icon: Path to the window's icon file.
- • backgroundColor: Background color of the window (e.g., '#fff' or 'rgb(255, 255, 255)').
- Web Content Control, webPreferences: An object containing further options related to the web page loaded in the window
- • preload: Path to a preload script. This script runs in a separate context before the renderer process starts and has access to both Node.js and browser APIs. Crucial for secure communication between main and renderer.
- • nodeIntegration: Enables Node.js integration in the renderer process (use with caution due to security implications, prefer preload scripts).
- • contextIsolation: Isolates the renderer's JavaScript context (recommended for security).
- • sandbox: Runs the renderer process in a sandboxed environment, further increasing security.
- • devTools: Whether to enable DevTools (default: true).
- • partition: Use a custom storage partition.
- • zoomFactor: Default zoom level.
- • javascript: Whether to enable JavaScript execution (usually leave as true).
- Other:
- • show: Whether to show the window immediately after creation (default: true). It's often better to show the window after the 'ready-to-show' event to avoid flickering.
- • parent: Makes the current window a child of another BrowserWindow instance.
- • modal: Creates a modal window (requires a parent window).
- • hasShadow: Whether the window has a shadow.
Electron context:
AngularElectron context:
Front context:
Comments (
)
Link to this page:
http://www.vb-net.com/AngularElectron/BrowserWindowOptions.htm
|