Zum Hauptteil springen

BrowserWindowConstructorOptions Objekt

  • width Integer (optional) - Fensterbreite in Pixel. Standard ist 800.
  • height Integer (optional) - Fensterhöhe in Pixel. Standard ist 600.
  • x Integer (optional) - (notwendig wenn y gegeben wird) der x-Versatz des Fensters zum Bildschirm. Standardmäßig wird das Fenster zentriert.
  • y Integer (optional) - (notwendig wenn x gegeben wird) der y-Versatz des Fensters zum Bildschirm. Standardmäßig wird das Fenster zentriert.
  • useContentSize boolean (optional) - Die width und height Werte werden als Größe der angezeigten Webseite verwendet. D.h. die tatsächliche Größe des Fensters beinhaltet noch die Rahmengröße und ist deshalb etwas größer. Standard ist false.
  • center boolean (optional) - Zeige das Fenster in der Mitte des Bildschirms. Standard ist false.
  • minWidth Integer (optional) - die minimale Fensterbreite. Standard ist 0.
  • minHeight Integer (optional) - die minimale Fensterhöhe. Standard ist 0.
  • maxWidth Integer (optional) - die maximale Fensterbreite. Der Standardwert ist kein Limit.
  • maxHeight Integer (optional) - die maximale Fensterhöhe. Der Standardwert ist kein Limit.
  • resizable boolean (optional) - Gibt an, ob die Fenstergröße geändert werden kann. Standard ist true.
  • movable boolean (optional) macOS Windows - Whether window is movable. This is not implemented on Linux. Standard ist true.
  • minimizable boolean (optional) macOS Windows - Whether window is minimizable. This is not implemented on Linux. Standard ist true.
  • maximizable boolean (optional) macOS Windows - Whether window is maximizable. This is not implemented on Linux. Standard ist true.
  • closable boolean (optional) macOS Windows - Whether window is closable. This is not implemented on Linux. Standard ist true.
  • focusable boolean (optional) - Gibt an ob das Fenster fokussiert werden kann. Standard ist true. Unter Windows impliziert die Option focusable: false die Option skipTaskbar: true. Unter Linux sorgt focusable: false dafür dass das Fenster nicht mehr mit dem Fenstermanager interagiert, d.h. das Fenster bleibt in allen Arbeitsoberflächen ganz oben.
  • alwaysOnTop boolean (optional) - Gibt an ob das Fenster immer über anderen Fenstern angezeigt werden soll. Standard ist false.
  • fullscreen boolean (optional) - Gibt an ob das Fenster im Vollbildmodus angezeigt werden soll. Wenn diese Option explizit auf false gesetzt wird, wird der Button für Vollbildmodus unter macOS versteckt oder deaktiviert. Standard ist false.
  • fullscreenable boolean (optional) - Gibt an ob das Fenster in den Vollbildmodus versetzt werden kann. Unter macOS gibt diese Option auch an, ob der Maximieren/Zoom Button das Fenster in den Vollbildmodus versetzt oder maximiert. Standard ist true.
  • simpleFullscreen boolean (optional) macOS - Use pre-Lion fullscreen on macOS. Standard ist false.
  • skipTaskbar boolean (optional) macOS Windows - Whether to show the window in taskbar. Standard ist false.
  • hiddenInMissionControl boolean (optional) macOS - Whether window should be hidden when the user toggles into mission control.
  • kiosk boolean (optional) - Gibt an, ob der Benutzer eingeschränkte Rechte besitzt (Kiosk-Modus). Standard ist false.
  • Titel string (optional) - der Standardfenstertitel. Standard ist "Electron". Wenn der HTML-Tag <title> in der von loadUrl() geladenen HTML-Datei festgelegt ist, dann wird dieser Wert ignoriert.
  • icon (NativeImage | string) (optional) - The window icon. Es empfiehlt sich, unter Windows ein ICO Icon zu verwenden, um die besten visuellen Effekte zu erreichen. Das Icon des ausführbaren Programmes wird verwendet, wenn dieser Wert nicht definiert wird.
  • show boolean (optional) - Gibt an ob das Fenster angezeigt wird, sobald es erstellt wurde. Standard ist true.
  • paintWhenInitiallyHidden boolean (optional) - Gibt an, ob der Renderer aktiv sein soll, wenn show false ist und das Fenster gerade erstellt wurde. Damit document.visibilityState beim ersten Laden mit show: false korrekt funktioniert, sollten Sie diesen Wert auf falsesetzen. Wenn Sie diese Einstellung auf false festlegen, wird das ready-to-show -Ereignis nicht ausgelöst. Standard ist true.
  • frame boolean (optional) - Specify false to create a frameless window. Standard ist true.
  • parent BrowserWindow (optional) - Geben Sie das übergeordnete Fenster an. Standard ist null.
  • modal boolean (optional) - Gibt an, ob es das Fenster ein modales Fenster sein soll. Diese Funktion funktioniert nur, wenn das Fenster ein untergeordnetes Fenster ist. Standard ist false.
  • acceptFirstMouse boolean (optional) macOS - Whether clicking an inactive window will also click through to the web contents. Default is false on macOS. This option is not configurable on other platforms.
  • disableAutoHideCursor boolean (optional) - Ob der Cursor ausgeblendet werden soll, wenn der Benutzer tippt. Standard ist false.
  • autoHideMenuBar boolean (optional) - Blendet die Menüleiste automatisch aus, es sei denn, die Alt Taste wird gedrückt. Standard ist false.
  • enableLargerThanScreen boolean (optional) macOS - Enable the window to be resized larger than screen. Only relevant for macOS, as other OSes allow larger-than-screen windows by default. Standard ist false.
  • backgroundColor string (optional) - The window's background color in Hex, RGB, RGBA, HSL, HSLA or named CSS color format. Alpha in #AARRGGBB format is supported if transparent is set to true. Der Standardwert ist #FFF (weiß). Siehe win.setBackgroundColor für weitere Informationen.
  • hasShadow boolean (optional) - Gibt an, ob das Fenster einen Schatten haben soll. Standard ist true.
  • opacity number (optional) macOS Windows - Set the initial opacity of the window, between 0.0 (fully transparent) and 1.0 (fully opaque). This is only implemented on Windows and macOS.
  • darkTheme boolean (optional) - Erzwingt ein dunkles Farbschema. Funktioniert nur mit manchen GTK+3 Desktopumgebungen. Standard ist false.
  • transparent boolean (optional) - Macht das Fenster transparent. Standard ist false. Unter Windows funktioniert es nur, wenn das Fenster rahmenlos ist.
  • type string (optional) - Der Fenstertyp. Standard ist ein normales Fenster. Mehr dazu kann weiter unten gelesen werden.
  • visualEffectState string (optional) macOS - Specify how the material appearance should reflect window activity state on macOS. Must be used with the vibrancy property. Mögliche Werte sind:
    • followWindow - The backdrop should automatically appear active when the window is active, and inactive when it is not. This is the default.
    • active - The backdrop should always appear active.
    • inactive - The backdrop should always appear inactive.
  • titleBarStyle string (optional) macOS Windows - The style of window title bar. Standard ist default. Mögliche Werte sind:
    • default - Results in the standard title bar for macOS or Windows respectively.
    • hidden - Results in a hidden title bar and a full size content window. On macOS, the window still has the standard window controls (“traffic lights”) in the top left. On Windows, when combined with titleBarOverlay: true it will activate the Window Controls Overlay (see titleBarOverlay for more information), otherwise no window controls will be shown.
    • hiddenInset macOS - Only on macOS, results in a hidden title bar with an alternative look where the traffic light buttons are slightly more inset from the window edge.
    • customButtonsOnHover macOS - Only on macOS, results in a hidden title bar and a full size content window, the traffic light buttons will display when being hovered over in the top left of the window. Beachte: Diese Option ist experimentell.
  • trafficLightPosition Point (optional) macOS - Set a custom position for the traffic light buttons in frameless windows.
  • roundedCorners boolean (optional) macOS - Whether frameless window should have rounded corners on macOS. Standard ist true. Setting this property to false will prevent the window from being fullscreenable.
  • thickFrame boolean (optional) - Use WS_THICKFRAME style for frameless windows on Windows, which adds standard window frame. Fensterschatten und Fensteranimationen werden entfernt wenn dieser Wert false ist. Standard ist true.
  • vibrancy string (optional) macOS - Add a type of vibrancy effect to the window, only on macOS. Can be appearance-based, titlebar, selection, menu, popover, sidebar, header, sheet, window, hud, fullscreen-ui, tooltip, content, under-window, or under-page.
  • backgroundMaterial string (optional) Windows - Set the window's system-drawn background material, including behind the non-client area. Can be auto, none, mica, acrylic or tabbed. Siehe win.setBackgroundMaterial für weitere Informationen.
  • zoomToPageWidth boolean (optional) macOS - Controls the behavior on macOS when option-clicking the green stoplight button on the toolbar or by clicking the Window > Zoom menu item. If true, the window will grow to the preferred width of the web page when zoomed, false will cause it to zoom to the width of the screen. This will also affect the behavior when calling maximize() directly. Standard ist false.
  • tabbingIdentifier string (optional) macOS - Tab group name, allows opening the window as a native tab. Windows with the same tabbing identifier will be grouped together. This also adds a native new tab button to your window's tab bar and allows your app and window to receive the new-window-for-tab event.
  • webPreferences WebPreferences (optional) - Einstellungen der Webseiten-Funktionen.
    • devTools boolean (optional) - Gibt an ob die Entwicklerwerkzeuge aktiviert sind. Falls dies auf false gesetzt ist, kann BrowserWindow.webContents.openDevTools() nicht verwendet werden um die Entwicklerwerkzeuge zu öffnen. Standard ist true.
    • nodeIntegration boolean (optional) - Whether node integration is enabled. Standard ist false.
    • nodeIntegrationsInWorker boolean (optional) - Gibt an ob die Node Integration in Web Workern aktiviert ist. Standard ist false. Mehr dazu kann in Multithreading gefunden werden.
    • nodeIntegrationInSubFrames boolean (optional) - Experimental option for enabling Node.js support in sub-frames such as iframes and child windows. All your preloads will load for every iframe, you can use process.isMainFrame to determine if you are in the main frame or not.
    • preload string (optional) - Gibt ein Skript an das vor allen anderen Skripten geladen wird bevor andere Skripte der Seite ausgeführt werden. Dieses Skript hat immer Zugriff auf die Node APIs, unabhängig davon ob die Node Integration aktiviert ist oder nicht. Der Wert sollte der absolute Pfad zum Skript sein. Wenn die Node Integration ausgeschaltet ist, kann das Preload Skript globale Node Symbole in den Globalen Scope zurückbringen. Siehe dieses Beispiel.
    • sandbox boolean (optional) - Wenn gesetzt, wird der Renderer des Fensters in einer Sandbox ausgeführt, wodurch es kompatibel mit der Chromium Sandbox wird und die Node.js Integration deaktiviert wird. Dies ist nicht das gleiche wie nodeIntegration, da die APIs die dem Preload Skript zur Verfügung stehen stärker limitiert sind. Lesen sie hier mehr über diese Option.
    • session Session (optional) - Sets the session used by the page. Instead of passing the Session object directly, you can also choose to use the partition option instead, which accepts a partition string. When both session and partition are provided, session will be preferred. Default is the default session.
    • partition string (optional) - Sets the session used by the page according to the session's partition string. If partition starts with persist:, the page will use a persistent session available to all pages in the app with the same partition. If there is no persist: prefix, the page will use an in-memory session. By assigning the same partition, multiple pages can share the same session. Default is the default session.
    • zoomFactor number (optional) - The default zoom factor of the page, 3.0 represents 300%. Standard ist 1.0.
    • javascript boolean (optional) - Enables JavaScript support. Standard ist true.
    • webSecurity boolean (optional) - When false, it will disable the same-origin policy (usually using testing websites by people), and set allowRunningInsecureContent to true if this options has not been set by user. Standard ist true.
    • allowRunningInsecureContent boolean (optional) - Allow an https page to run JavaScript, CSS or plugins from http URLs. Standard ist false.
    • images boolean (optional) - Enables image support. Standard ist true.
    • imageAnimationPolicy string (optional) - Specifies how to run image animations (E.g. GIFs). Kann animate, animateOnce oder noAnimation sein. Standard ist animate.
    • textAreasAreResizable boolean (optional) - Make TextArea elements resizable. Standard ist true.
    • webgl boolean (optional) - Enables WebGL support. Standard ist true.
    • plugins boolean (optional) - Whether plugins should be enabled. Standard ist false.
    • experimentalFeatures boolean (optional) - Enables Chromium's experimental features. Standard ist false.
    • scrollBounce boolean (optional) macOS - Enables scroll bounce (rubber banding) effect on macOS. Standard ist false.
    • enableBlinkFeatures string (optional) - A list of feature strings separated by ,, like CSSVariables,KeyboardEventKey to enable. Die vollständige Liste der unterstützten Funktione-strings finden Sie in der RuntimeEnabledFeatures.json5 Datei.
    • disableBlinkFeatures string (optional) - A list of feature strings separated by ,, like CSSVariables,KeyboardEventKey to disable. Die vollständige Liste der unterstützten Feature-strings finden Sie in der RuntimeEnabledFeatures.json5 Datei.
    • defaultFontFamily Object (optional) - Sets the default font for the font-family.
      • standard string (optional) - Defaults to Times New Roman.
      • serif string (optional) - Defaults to Times New Roman.
      • sansSerif string (optional) - Defaults to Arial.
      • monospace string (optional) - Defaults to Courier New.
      • cursive string (optional) - Defaults to Script.
      • fantasy string (optional) - Defaults to Impact.
      • math string (optional) - Defaults to Latin Modern Math.
    • defaultFontSize Integer (optional) - Standart ist 16.
    • defaultMonospaceFontSize Integer (optional) - Standart ist 13.
    • minimumFontSize Integer (optional) - Standart ist 0.
    • defaultEncoding string (optional) - Defaults to ISO-8859-1.
    • backgroundThrottling boolean (optional) - Whether to throttle animations and timers when the page becomes background. Dies wirkt sich auch auf die Page Visibility API aus. When at least one webContents displayed in a single browserWindow has disabled backgroundThrottling then frames will be drawn and swapped for the whole window and other webContents displayed by it. Standardwert ist true.
    • offscreen boolean (optional) - Whether to enable offscreen rendering for the browser window. Standardwert ist false. See the offscreen rendering tutorial for more details.
    • contextIsolation boolean (optional) - Whether to run Electron APIs and the specified preload script in a separate JavaScript context. Defaults to true. The context that the preload script runs in will only have access to its own dedicated document and window globals, as well as its own set of JavaScript builtins (Array, Object, JSON, etc.), which are all invisible to the loaded content. The Electron API will only be available in the preload script and not the loaded page. This option should be used when loading potentially untrusted remote content to ensure the loaded content cannot tamper with the preload script and any Electron APIs being used. Diese Option verwendet die gleiche Technik, wie sie von Chrome Content Scripts verwendet wird. You can access this context in the dev tools by selecting the 'Electron Isolated Context' entry in the combo box at the top of the Console tab.
    • webviewTag boolean (optional) - Whether to enable the <webview> tag. Standardwert ist false. Note: The preload script configured for the <webview> will have node integration enabled when it is executed so you should ensure remote/untrusted content is not able to create a <webview> tag with a possibly malicious preload script. You can use the will-attach-webview event on webContents to strip away the preload script and to validate or alter the <webview>'s initial settings.
    • additionalArguments string[] (optional) - A list of strings that will be appended to process.argv in the renderer process of this app. Useful for passing small bits of data down to renderer process preload scripts.
    • safeDialogs boolean (optional) - Whether to enable browser style consecutive dialog protection. Standard ist false.
    • safeDialogsMessage string (optional) - The message to display when consecutive dialog protection is triggered. If not defined the default message would be used, note that currently the default message is in English and not localized.
    • disableDialogs boolean (optional) - Whether to disable dialogs completely. Overrides safeDialogs. Standard ist false.
    • navigateOnDragDrop boolean (optional) - Whether dragging and dropping a file or link onto the page causes a navigation. Standard ist false.
    • autoplayPolicy string (optional) - Autoplay policy to apply to content in the window, can be no-user-gesture-required, user-gesture-required, document-user-activation-required. Defaults to no-user-gesture-required.
    • disableHtmlFullscreenWindowResize boolean (optional) - Whether to prevent the window from resizing when entering HTML Fullscreen. Default is false.
    • accessibleTitle string (optional) - An alternative title string provided only to accessibility tools such as screen readers. This string is not directly visible to users.
    • spellcheck boolean (optional) - Whether to enable the builtin spellchecker. Standard ist true.
    • enableWebSQL boolean (optional) - Whether to enable the WebSQL api. Standard ist true.
    • v8CacheOptions string (optional) - Enforces the v8 code caching policy used by blink. Accepted values are
      • none - Disables code caching
      • code - Heuristic based code caching
      • bypassHeatCheck - Bypass code caching heuristics but with lazy compilation
      • bypassHeatCheckAndEagerCompile - Same as above except compilation is eager. Default policy is code.
    • enablePreferredSizeMode boolean (optional) - Whether to enable preferred size mode. The preferred size is the minimum size needed to contain the layout of the document—without requiring scrolling. Enabling this will cause the preferred-size-changed event to be emitted on the WebContents when the preferred size changes. Standard ist false.
  • titleBarOverlay Object | Boolean (optional) - Bei Verwendung eines framellosen Fensters in Verbindung mit win.setWindowButtonVisibility(true) auf macOS oder mit titleBarStyle, so dass die Standard-Fenster-Kontrolle ("Ampel" auf macOS) sichtbar ist, diese Eigenschaft aktiviert das Fenstersteuerungs-Overlay JavaScript-APIs und CSS-Umgebungsvariablen. Specifying true will result in an overlay with default system colors. Standard ist false.
    • color String (optional) Windows - The CSS color of the Window Controls Overlay when enabled. Default is the system color.
    • symbolColor String (optional) Windows - The CSS color of the symbols on the Window Controls Overlay when enabled. Default is the system color.
    • height Integer (optional) macOS Windows - The height of the title bar and Window Controls Overlay in pixels. Default is system height.

When setting minimum or maximum window size with minWidth/maxWidth/ minHeight/maxHeight, it only constrains the users. It won't prevent you from passing a size that does not follow size constraints to setBounds/setSize or to the constructor of BrowserWindow.

The possible values and behaviors of the type option are platform dependent. Mögliche Werte sind:

  • On Linux, possible types are desktop, dock, toolbar, splash, notification.
    • Der Typ desktop platziert das Fenster auf der Ebene des Hintergrundfensters (kCGDesktopWindowLevel - 1). Beachten sie jedoch, dass ein Desktop-Fenster keine focus, keyboard und mouse Events empfängt. Sie können weiterhin globalShortcut verwenden um Eingaben sparsam zu erhalten.
    • Der Typ dock erzeugt ein Dock-ähnliches Fensterverhalten.
    • Der Typ toolbar erzeugt ein Fenster mit einer Symbolleiste.
    • Der Typ splash verhält sich auf eine bestimmte Weise. Es ist kein Draggabel, auch wenn das CSS-Styling des Fensterkörpers -webkit-app-region: drag enthält. Dieser Typ wird häufig für Splash-Screens verwendet.
    • Der Typ notification erstellt ein Fenster, das sich wie eine Systembenachrichtigung verhält.
  • On macOS, possible types are desktop, textured, panel.
    • The textured type adds metal gradient appearance (NSWindowStyleMaskTexturedBackground).
    • The desktop type places the window at the desktop background window level (kCGDesktopWindowLevel - 1). Note that desktop window will not receive focus, keyboard or mouse events, but you can use globalShortcut to receive input sparingly.
    • The panel type enables the window to float on top of full-screened apps by adding the NSWindowStyleMaskNonactivatingPanel style mask,normally reserved for NSPanel, at runtime. Also, the window will appear on all spaces (desktops).
  • On Windows, possible type is toolbar.