Saltar al contenido principal

BrowserWindowConstructorOptions Object

  • width Integer (opcional) - El ancho de la ventana en pixeles. Por defecto es 800.
  • height Integer (opcional) - La altura de la ventana en pixeles. Por defecto es 600.
  • x Integer (opcional) - (required si y es usado) Desplazamiento a la izquierda de la ventana de la pantalla. Por defecto es centrar en la ventana.
  • y Integer (opcional) - (required si x es usado) Desplazamiento superior de la ventana desde la pantalla. Por defecto es centrar en la ventana.
  • useContentSize boolean (opcional) - width y height se utilizan como el tamaño de la página web. Esto significa que el tamaño actual de la ventana incluirá el tamaño del marco de la ventana y será un poco más grande. Por defecto es false.
  • center boolean (opcional) - Muestra la ventana en el centro de la pantalla. Por defecto es false.
  • minWidth Integer (opcional) - Ancho mínimo de a ventana. Por defecto es 0.
  • minHeight Integer (opcional) - Altura mínima de la ventana. Por defecto es 0.
  • maxWidth Integer (opcional) - Ancho máximo de la ventana. Por defecto no hay limite.
  • maxHeight Integer (opcional) - Altura máxima de la ventana. Por defecto no hay limite.
  • resizable boolean (opcional) - Si la ventana puede ser redimencionada. Por defecto es true.
  • movable boolean (optional) macOS Windows - Whether window is movable. This is not implemented on Linux. Por defecto es true.
  • minimizable boolean (optional) macOS Windows - Whether window is minimizable. This is not implemented on Linux. Por defecto es true.
  • maximizable boolean (optional) macOS Windows - Whether window is maximizable. This is not implemented on Linux. Por defecto es true.
  • closable boolean (optional) macOS Windows - Whether window is closable. This is not implemented on Linux. Por defecto es true.
  • focusable boolean (opcional) - si la ventana se puede enfocar. Por defecto es true. En Windows, la configuración focusable: false también quiere decir que skipTaskbar: true. En Linux, la configuración focusable: false hace que la ventana deje de interactuar con wm, así la ventana siempre se mantendrá en la parte superior en todas las áreas de trabajo.
  • alwaysOnTop boolean (opcional) - Si la ventana debería permanecer siempre por ensima de otras ventanas. Por defecto es false.
  • fullscreen boolean(opcional) - si la ventana debería mostrarse en pantalla completa. Cuando se establece explícitamente false el botón de la pantalla completa estará oculta o deshabilitada en macOS. Por defecto es false.
  • fullscreenable boolean (opcional) - si la ventana puede ponerse el modo pantalla completa. En macOS, también si el botón maximizar o acercarse debería alternar el modo pantalla completa o maximizar la ventana. Por defecto es true.
  • simpleFullscreen boolean (optional) macOS - Use pre-Lion fullscreen on macOS. Por defecto es false.
  • skipTaskbar boolean (optional) macOS Windows - Whether to show the window in taskbar. Por defecto es false.
  • hiddenInMissionControl boolean (optional) macOS - Whether window should be hidden when the user toggles into mission control.
  • kiosk boolean (opcional) - Si la ventana está en modo kiosk. Por defecto es false.
  • title string (opcional) - Titulo de la ventana por defecto. Por defecto es "Electron". Si la etiqueta HTML <title> es definida en el archivo HTML cargado por loadURL(), esta propiedad será ignorada.
  • icon (NativeImage | string) (optional) - The window icon. En Windows, se recomienda usar iconos ICO para obtener mejores efectos visuales. También se se puede dejar sin definir, de esta manera se utilizará el icono del ejecutable.
  • show boolean (opcional) - Si la ventana debería ser mostrada cuando se crea. Por defecto es true.
  • paintWhenInitiallyHidden boolean (opcional) - Si el renderer debería estar activo cuando show es false y recién ha sido creado. Para que document.visibilityState funcione correctamente en la primera carga con show: false debería establecer esto a false. Estableciendo esto a false causará que el evento ready-to-show no se dispare. Por defecto es true.
  • frame boolean (opcional) - Especifica false para crear un Frameless Window.helloworlds Por defecto es true.
  • parent BrowserWindow (opcional) - Especifica la ventana padre. Por defecto es null.
  • modal boolean (opcional) - Si es una ventana modal. Esto sólo funciona cuando la ventana es una ventana hija. Por defecto es false.
  • acceptFirstMouse booleano (opcional) macOS - Si hacer clic en una ventana inactiva también hará clic a través del contenido web. Default is false on macOS. This option is not configurable on other platforms.
  • disableAutoHideCursor boolean (opcional) - Si ocultar el cursor cuando se está escriniendo. Por defecto es false.
  • autoHideMenuBar boolean (opcional) - Auto ocultar la barra de menú a menos que la tecla Alt este presionada. Por defecto es 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. Por defecto es 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. Por defecto es #FFF (blanco). See win.setBackgroundColor for more information.
  • hasShadow boolean (opcional) - Si la ventana debería tener una sombra. Por defecto es 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 (opcional) - Fuerza el uso del tema obscuro en la ventana, solo funciona en algunos entornos de escritorio GTK+3. Por defecto es false.
  • transparent boolean (opcional) - Hace la ventana tranparente. Por defecto es false. En Windows, no funciona a menos que la ventana sea sin marco.
  • type string (opcional) - El tipo de ventana, por defecto es una ventana normal. Vea más sobre esto a continuación.
  • visualEffectState string (optional) macOS - Specify how the material appearance should reflect window activity state on macOS. Must be used with the vibrancy property. Los valores posibles son:
    • followWindow - The backdrop should automatically appear active when the window is active, and inactive when it is not. Este es el valor predeterminado.
    • 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. Por defecto es default. Los valores posibles son:
    • 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. Nota: Actualmente esta opción es experimental.
  • 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. Por defecto es true. Setting this property to false will prevent the window from being fullscreenable.
  • thickFrame boolean (opcional) - Utilice el estilo WS_THICKFRAME para ventanas sin marco en Windows, la cual agrega un marco de ventana estándar. Configurarlo en false eliminará la sombra de la ventana y las animaciones de la ventana. Por defecto es 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. Puede ser auto, none, mica, acrylic o tabbed. See win.setBackgroundMaterial for more information.
  • 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. Por defecto es 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) - Settings of web page's features.
    • devTools boolean (opcional) - Si se habilita el DevTools. Si se configura a false, no puede utilizarse BrowserWindow.webContents.openDevTools() para abrir DevTools. Por defecto es true.
    • nodeIntegration boolean (optional) - Whether node integration is enabled. Por defecto es false.
    • nodeIntegrationInWorker boolean (opcional) - Si la integración de nodos está habilitada en los trabajadores de la web. Por defecto es false. Se pueden encontrar más detalles en Multithreading.
    • nodeIntegrationInSubFrames boolean (opcional) - Opcion experimental para habilitar soporte Node.js en sub-frames como iframes y ventas hijos. Todos tus preloads cargarán por cada iframe, puedes usar process.isMainFrame para determinar si estás en el marco principal o no.
    • preload string (opcional) - Especifica un script que será cargado antes del otros scripts en la página. Este script siempre tendrá acceso al nodo APIs sin importar si la integración de nodos esté activada o no. El valor debería ser la ruta del archivo absoluto al script. Cuando la integración de nodos esta desactivada, la precarga del script puede reintroducir de vuelta al ámbito global los símbolos globales del Nodo. Ver ejemplo aquí.
    • sandbox boolean (opcional) - Si se configura, protegerá al renderizador asociado a la ventana, haciéndolo compatible con el sandbox de Chromium OS-level, deshabilitando el motor Node.js. Esto no es lo mismo que la opción de nodeIntegration y las APIs disponibles para el script de precarga son más limitadas. Leer más sobre la opción aquí.
    • session Session (opcional) - Configura la sesión usada por la página. En lugar de pasar directamente el objeto de la sesión, se puede optar por utilizar la opción de partition, la cual acepta una cadena de partición. Cuando se proporcionen session y partition, se preferirá session. Default es la sesión por defecto.
    • partition cadena (opcional) - Configura la sesión utilizada por la página según la cadena de partición de la sesión. Si la partition empieza con persist:, la página utilizará una sesión persistente disponible para todas las páginas en la partición con la misma partition. Si no está el prefijo persist:, la página usara una sesión de la memoria interna. Al asignar la misma partition, las páginas múltiples pueden compartir la misma sesión. Default es la sesión por defecto.
    • zoomFactor number (optional) - The default zoom factor of the page, 3.0 represents 300%. Por defecto es 1.0.
    • javascript boolean (optional) - Enables JavaScript support. Por defecto es true.
    • webSecurity boolean (opcional) - Cuando es false, desactivará la política de same-origin (por lo general se utiliza cuando la gente prueba los sitios web), y configurará allowRunningInsecureContenta true en caso de que estas opciones no hayan sido configuradas por el usuario. Por defecto es true.
    • allowRunningInsecureContent boolean (optional) - Allow an https page to run JavaScript, CSS or plugins from http URLs. Por defecto es false.
    • images boolean (optional) - Enables image support. Por defecto es true.
    • imageAnimationPolicy string (opcional) - Especifica cómo correr la animaciones de la imagen (P.e. GIFs). Puede ser animate, animateOnce o noAnimation. Por defecto es animate.
    • textAreasAreResizable boolean (optional) - Make TextArea elements resizable. Default is true.
    • webgl boolean (optional) - Enables WebGL support. Por defecto es true.
    • plugins boolean (optional) - Whether plugins should be enabled. Por defecto es false.
    • experimentalFeatures boolean (optional) - Enables Chromium's experimental features. Por defecto es false.
    • scrollBounce boolean (optional) macOS - Enables scroll bounce (rubber banding) effect on macOS. Por defecto es false.
    • enableBlinkFeatures string (opcional) - Una lista de cadenas de características separadas por ,, para habilitar como CSSVariables,KeyboardEventKey. La lista completa de cadenas distintivas soportadas pueden encontrarse en el archivo RuntimeEnabledFeatures.json5.
    • disableblinkFeatures string (opcional) - Una lista de cadenas distintivas separadas por ,,como CSSVariables,KeyboardEventKey para deshabilitar. La lista completa de cadenas características soportadas puede ser encontrada en el archivo RuntimeEnabledFeatures.json5.
    • defaultFontFamily Object (optional) - Sets the default font for the font-family.
      • standard string (opcional) - Por defecto es Times New Roman.
      • serif string (opcional) - Por defecto es Times New Roman.
      • sansSerif string (opcional) - Por defecto es Arial.
      • monospace string (opcional) - Por defecto es Courier New.
      • cursive string (opcional) - Por defecto es Script.
      • fantasy string (opcional) - Por defecto es Impact.
      • math string (optional) - Defaults to Latin Modern Math.
    • defaultFontSize Integer (opcional) - Por defecto es 16.
    • defaultMonospaceFontSize Integer (opcional) - Por defecto es 13.
    • minimumFontSize Integer (opcional) - Por defecto es 0.
    • defaultEncoding string (opcional) - Por defecto es ISO-8859-1.
    • backgroundThrottling boolean (opcional) - Para acelerar animaciones y temporizadores cuando la página esta al fondo. Esto también afecta a Page Visibility API. 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. Por defecto es true.
    • offscreen boolean(optional) - Para habilitar el renderizado offscreen para el navegador de la ventana. Por defecto es false. Para más detalles, ver offscreen rendering tutorial.
    • contextIsolation boolean(opcional) - Para ejecutar las APIs de Electron y el script especificado preload en un contexto JavaScript independiente. Por defecto es 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. Esta opción utiliza la misa técnica usada por Chrome Content Scripts. 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 (opcional) - Si se habilita o no el <webview> tag. Por defecto es false. Nota: El script preload configurado para el <webview>tendrá la integración de nodos habilitada cuando se ejecuta por lo que hay que asegurarse que el contenido remoto o posiblemente dañino no sea capaz de crear una etiqueta de <webview>con un script preload posiblemente malicioso. Puede utilizarse el evento will-attach-webview en webContents para quitar el script preload y validar o alterar la configuración inicial de <webview>.
    • 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. Por defecto es false.
    • safeDialogsMessage string (opcional) - El mensaje a mostrar cuando la protección de diálogo consecutivo es lanzada. So no se define el mensaje por defecto sería utilizado, note que actualmente el mensaje por defecto esta en Inglés y no localizado.
    • disableDialogs boolean (optional) - Whether to disable dialogs completely. Overrides safeDialogs. Por defecto es false.
    • navigateOnDragDrop boolean (optional) - Whether dragging and dropping a file or link onto the page causes a navigation. Por defecto es false.
    • autoplayPolicy string (opcional) - Política de autoplay para aplicar al contenido en la ventana, puede ser no-user-gesture-required, user-gesture-required, document-user-activation-required. Por defecto a 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. Esta cadena no es directamente visible para los usuarios.
    • spellcheck boolean (optional) - Whether to enable the builtin spellchecker. Por defecto es true.
    • enableWebSQL boolean (optional) - Whether to enable the WebSQL api. Por defecto es 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. Por defecto es false.
  • titleBarOverlay Object | Boolean (optional) - When using a frameless window in conjunction with win.setWindowButtonVisibility(true) on macOS or using a titleBarStyle so that the standard window controls ("traffic lights" on macOS) are visible, this property enables the Window Controls Overlay JavaScript APIs and CSS Environment Variables. Especificar true dará como resultado un overlay con los colores del sistema predeterminados. Por defecto es 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.

Cuando se configura el tamaño máximo o mínimo de la ventana con minWidth/maxWidth/ minHeight/maxHeight, solo limita a los usuarios. No impide pasar de un tamaño que no sigue las restricciones de tamaño asetBounds/setSize o al constructor de BrowserWindow.

Los posibles valores y comportamientos de la opción type son dependientes de la plataforma. Los valores posibles son:

  • En linux, los tipos posibles son desktop, dock, toolbar, splash, notification.
    • The desktop type places the window at the desktop background window level (kCGDesktopWindowLevel - 1). However, note that a desktop window will not receive focus, keyboard, or mouse events. You can still use globalShortcut to receive input sparingly.
    • The dock type creates a dock-like window behavior.
    • The toolbar type creates a window with a toolbar appearance.
    • The splash type behaves in a specific way. It is not draggable, even if the CSS styling of the window's body contains -webkit-app-region: drag. This type is commonly used for splash screens.
    • The notification type creates a window that behaves like a system notification.
  • On macOS, possible types are desktop, textured, panel.
    • El tipo textured añade una aspecto de tono metálico (NSWindowStyleMaskTexturedBackground).
    • El tipo desktop coloca la ventana en el nivel de la ventana de fondo de escritorio (kCGDesktopWindowLevel - 1). Tenga en cuenta que la ventana de escritorio no recibirá enfoque alguno, ni eventos del ratón o del teclado, pero se puede utilizar globalShortcut para recibir input con moderación.
    • 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).
  • En Windows, el tipo posible es toolbar.