diff --git a/docs/fiddles/menus/customize-menus/index.html b/docs/fiddles/menus/customize-menus/index.html index 1c2c64d70e..9d077d35d5 100644 --- a/docs/fiddles/menus/customize-menus/index.html +++ b/docs/fiddles/menus/customize-menus/index.html @@ -1,128 +1,128 @@ - - - - - Customize Menus - - - -
-

Customize Menus

- -

- The Menu and MenuItem modules can be used to - create custom native menus. -

- -

- There are two kinds of menus: the application (top) menu and context - (right-click) menu. -

- -

- Open the - full API documentation(opens in new window) - in your browser. -

-
- -
-

Create an application menu

-
-
-

- The Menu and MenuItem modules allow you to - customize your application menu. If you don't set any menu, Electron - will generate a minimal menu for your app by default. -

- -

- If you click the 'View' option in the application menu and then the - 'App Menu Demo', you'll see an information box displayed. -

- -
-

ProTip

- Know operating system menu differences. -

- When designing an app for multiple operating systems it's - important to be mindful of the ways application menu conventions - differ on each operating system. -

-

- For instance, on Windows, accelerators are set with an - &. Naming conventions also vary, like between - "Settings" or "Preferences". Below are resources for learning - operating system specific standards. -

- -
-
-
-
- -
-

Create a context menu

-
-
-
- -
-

- A context, or right-click, menu can be created with the - Menu and MenuItem modules as well. You can - right-click anywhere in this app or click the demo button to see an - example context menu. -

- -

- In this demo we use the ipcRenderer module to show the - context menu when explicitly calling it from the renderer process. -

-

- See the full - context-menu event documentation - for all the available properties. -

-
-
-
- - - - + + + + + Customize Menus + + + +
+

Customize Menus

+ +

+ The Menu and MenuItem modules can be used to + create custom native menus. +

+ +

+ There are two kinds of menus: the application (top) menu and context + (right-click) menu. +

+ +

+ Open the + full API documentation(opens in new window) + in your browser. +

+
+ +
+

Create an application menu

+
+
+

+ The Menu and MenuItem modules allow you to + customize your application menu. If you don't set any menu, Electron + will generate a minimal menu for your app by default. +

+ +

+ If you click the 'View' option in the application menu and then the + 'App Menu Demo', you'll see an information box displayed. +

+ +
+

ProTip

+ Know operating system menu differences. +

+ When designing an app for multiple operating systems it's + important to be mindful of the ways application menu conventions + differ on each operating system. +

+

+ For instance, on Windows, accelerators are set with an + &. Naming conventions also vary, like between + "Settings" or "Preferences". Below are resources for learning + operating system specific standards. +

+ +
+
+
+
+ +
+

Create a context menu

+
+
+
+ +
+

+ A context, or right-click, menu can be created with the + Menu and MenuItem modules as well. You can + right-click anywhere in this app or click the demo button to see an + example context menu. +

+ +

+ In this demo we use the ipcRenderer module to show the + context menu when explicitly calling it from the renderer process. +

+

+ See the full + context-menu event documentation + for all the available properties. +

+
+
+
+ + + + diff --git a/docs/fiddles/menus/shortcuts/index.html b/docs/fiddles/menus/shortcuts/index.html index 6851357980..6ab24f828b 100644 --- a/docs/fiddles/menus/shortcuts/index.html +++ b/docs/fiddles/menus/shortcuts/index.html @@ -1,73 +1,73 @@ - - - - - - Keyboard Shortcuts - - - -
-

Keyboard Shortcuts

- -

The globalShortcut and Menu modules can be used to define keyboard shortcuts.

- -

- In Electron, keyboard shortcuts are called accelerators. - They can be assigned to actions in your application's Menu, - or they can be assigned globally so they'll be triggered even when - your app doesn't have keyboard focus. -

- -

- Open the full documentation for the - Menu, - Accelerator, - and - globalShortcut - APIs in your browser. -

- -
- -
-
-
-

- To try this demo, press CommandOrControl+Alt+K on your - keyboard. -

- -

- Global shortcuts are detected even when the app doesn't have - keyboard focus, and they must be registered after the app's - `ready` event is emitted. -

- -
-

ProTip

- Avoid overriding system-wide keyboard shortcuts. -

- When registering global shortcuts, it's important to be aware of - existing defaults in the target operating system, so as not to - override any existing behaviors. For an overview of each - operating system's keyboard shortcuts, view these documents: -

- - -
- -
-
-
- - - + + + + + + Keyboard Shortcuts + + + +
+

Keyboard Shortcuts

+ +

The globalShortcut and Menu modules can be used to define keyboard shortcuts.

+ +

+ In Electron, keyboard shortcuts are called accelerators. + They can be assigned to actions in your application's Menu, + or they can be assigned globally so they'll be triggered even when + your app doesn't have keyboard focus. +

+ +

+ Open the full documentation for the + Menu, + Accelerator, + and + globalShortcut + APIs in your browser. +

+ +
+ +
+
+
+

+ To try this demo, press CommandOrControl+Alt+K on your + keyboard. +

+ +

+ Global shortcuts are detected even when the app doesn't have + keyboard focus, and they must be registered after the app's + `ready` event is emitted. +

+ +
+

ProTip

+ Avoid overriding system-wide keyboard shortcuts. +

+ When registering global shortcuts, it's important to be aware of + existing defaults in the target operating system, so as not to + override any existing behaviors. For an overview of each + operating system's keyboard shortcuts, view these documents: +

+ + +
+ +
+
+
+ + + diff --git a/docs/fiddles/native-ui/dialogs/error-dialog/index.html b/docs/fiddles/native-ui/dialogs/error-dialog/index.html index 2d516c28b6..4f5c0a675f 100644 --- a/docs/fiddles/native-ui/dialogs/error-dialog/index.html +++ b/docs/fiddles/native-ui/dialogs/error-dialog/index.html @@ -1,81 +1,81 @@ - - - - - Error Dialog - - - -
-

Use system dialogs

- -

- The dialog module in Electron allows you to use native - system dialogs for opening files or directories, saving a file or - displaying informational messages. -

- -

- This is a main process module because this process is more efficient - with native utilities and it allows the call to happen without - interrupting the visible elements in your page's renderer process. -

- -

- Open the - - full API documentation (opens in new window) - - in your browser. -

-
- -
-
-

Error Dialog

-
-
- -
-

- In this demo, the ipc module is used to send a message - from the renderer process instructing the main process to launch the - error dialog. -

- -

- You can use an error dialog before the app's - ready event, which is useful for showing errors upon - startup. -

-
Renderer Process
-
-          
-const {ipcRenderer} = require('electron')
-
-const errorBtn = document.getElementById('error-dialog')
-
-errorBtn.addEventListener('click', (event) => {
-  ipcRenderer.send('open-error-dialog')
-})
-          
-
Main Process
-
-          
-const {ipcMain, dialog} = require('electron')
-
-ipcMain.on('open-error-dialog', (event) => {
-  dialog.showErrorBox('An Error Message', 'Demonstrating an error message.')
-})
-          
-        
-
-
-
- - - - + + + + + Error Dialog + + + +
+

Use system dialogs

+ +

+ The dialog module in Electron allows you to use native + system dialogs for opening files or directories, saving a file or + displaying informational messages. +

+ +

+ This is a main process module because this process is more efficient + with native utilities and it allows the call to happen without + interrupting the visible elements in your page's renderer process. +

+ +

+ Open the + + full API documentation (opens in new window) + + in your browser. +

+
+ +
+
+

Error Dialog

+
+
+ +
+

+ In this demo, the ipc module is used to send a message + from the renderer process instructing the main process to launch the + error dialog. +

+ +

+ You can use an error dialog before the app's + ready event, which is useful for showing errors upon + startup. +

+
Renderer Process
+
+          
+const {ipcRenderer} = require('electron')
+
+const errorBtn = document.getElementById('error-dialog')
+
+errorBtn.addEventListener('click', (event) => {
+  ipcRenderer.send('open-error-dialog')
+})
+          
+
Main Process
+
+          
+const {ipcMain, dialog} = require('electron')
+
+ipcMain.on('open-error-dialog', (event) => {
+  dialog.showErrorBox('An Error Message', 'Demonstrating an error message.')
+})
+          
+        
+
+
+
+ + + + diff --git a/docs/fiddles/native-ui/dialogs/information-dialog/index.html b/docs/fiddles/native-ui/dialogs/information-dialog/index.html index 5600b65387..005674e99b 100644 --- a/docs/fiddles/native-ui/dialogs/information-dialog/index.html +++ b/docs/fiddles/native-ui/dialogs/information-dialog/index.html @@ -1,104 +1,104 @@ - - - - - Information Dialog - - - -
-

Use system dialogs

- -

- The dialog module in Electron allows you to use native - system dialogs for opening files or directories, saving a file or - displaying informational messages. -

- -

- This is a main process module because this process is more efficient - with native utilities and it allows the call to happen without - interrupting the visible elements in your page's renderer process. -

- -

- Open the - - full API documentation (opens in new window) - - in your browser. -

-
- -
-
-

Information Dialog

-
-
- - -
-

- In this demo, the ipc module is used to send a message - from the renderer process instructing the main process to launch the - information dialog. Options may be provided for responses which can - then be relayed back to the renderer process. -

- -

- Note: The title property is not displayed in macOS. -

- -

- An information dialog can contain an icon, your choice of buttons, - title and message. -

-
Renderer Process
-
-            
-const {ipcRenderer} = require('electron')
-
-const informationBtn = document.getElementById('information-dialog')
-
-informationBtn.addEventListener('click', (event) => {
-  ipcRenderer.send('open-information-dialog')
-})
-
-ipcRenderer.on('information-dialog-selection', (event, index) => {
-  let message = 'You selected '
-  if (index === 0) message += 'yes.'
-  else message += 'no.'
-  document.getElementById('info-selection').innerHTML = message
-})
-            
-          
-
Main Process
-
-            
-const {ipcMain, dialog} = require('electron')
-
-ipcMain.on('open-information-dialog', (event) => {
-  const options = {
-    type: 'info',
-    title: 'Information',
-    message: "This is an information dialog. Isn't it nice?",
-    buttons: ['Yes', 'No']
-  }
-  dialog.showMessageBox(options, (index) => {
-    event.sender.send('information-dialog-selection', index)
-  })
-})
-            
-          
-
-
-
- - - - + + + + + Information Dialog + + + +
+

Use system dialogs

+ +

+ The dialog module in Electron allows you to use native + system dialogs for opening files or directories, saving a file or + displaying informational messages. +

+ +

+ This is a main process module because this process is more efficient + with native utilities and it allows the call to happen without + interrupting the visible elements in your page's renderer process. +

+ +

+ Open the + + full API documentation (opens in new window) + + in your browser. +

+
+ +
+
+

Information Dialog

+
+
+ + +
+

+ In this demo, the ipc module is used to send a message + from the renderer process instructing the main process to launch the + information dialog. Options may be provided for responses which can + then be relayed back to the renderer process. +

+ +

+ Note: The title property is not displayed in macOS. +

+ +

+ An information dialog can contain an icon, your choice of buttons, + title and message. +

+
Renderer Process
+
+            
+const {ipcRenderer} = require('electron')
+
+const informationBtn = document.getElementById('information-dialog')
+
+informationBtn.addEventListener('click', (event) => {
+  ipcRenderer.send('open-information-dialog')
+})
+
+ipcRenderer.on('information-dialog-selection', (event, index) => {
+  let message = 'You selected '
+  if (index === 0) message += 'yes.'
+  else message += 'no.'
+  document.getElementById('info-selection').innerHTML = message
+})
+            
+          
+
Main Process
+
+            
+const {ipcMain, dialog} = require('electron')
+
+ipcMain.on('open-information-dialog', (event) => {
+  const options = {
+    type: 'info',
+    title: 'Information',
+    message: "This is an information dialog. Isn't it nice?",
+    buttons: ['Yes', 'No']
+  }
+  dialog.showMessageBox(options, (index) => {
+    event.sender.send('information-dialog-selection', index)
+  })
+})
+            
+          
+
+
+
+ + + + diff --git a/docs/fiddles/native-ui/dialogs/open-file-or-directory/index.html b/docs/fiddles/native-ui/dialogs/open-file-or-directory/index.html index df96f2e810..dcf66587a8 100644 --- a/docs/fiddles/native-ui/dialogs/open-file-or-directory/index.html +++ b/docs/fiddles/native-ui/dialogs/open-file-or-directory/index.html @@ -1,108 +1,108 @@ - - - - - Open File or Directory - - - -
-

Use system dialogs

- -

- The dialog module in Electron allows you to use native - system dialogs for opening files or directories, saving a file or - displaying informational messages. -

- -

- This is a main process module because this process is more efficient - with native utilities and it allows the call to happen without - interrupting the visible elements in your page's renderer process. -

- -

- Open the - - full API documentation (opens in new window) - - in your browser. -

-
- -
-
-

Open a File or Directory

-
-
- - -
-

- In this demo, the ipc module is used to send a message - from the renderer process instructing the main process to launch the - open file (or directory) dialog. If a file is selected, the main - process can send that information back to the renderer process. -

-
Renderer Process
-
-          
-const {ipcRenderer} = require('electron')
-
-const selectDirBtn = document.getElementById('select-directory')
-
-selectDirBtn.addEventListener('click', (event) => {
-  ipcRenderer.send('open-file-dialog')
-})
-
-ipcRenderer.on('selected-directory', (event, path) => {
-  document.getElementById('selected-file').innerHTML = `You selected: ${path}`
-})
-          
-        
-
Main Process
-
-          
-const {ipcMain, dialog} = require('electron')
-
-ipcMain.on('open-file-dialog', (event) => {
-  dialog.showOpenDialog({
-    properties: ['openFile', 'openDirectory']
-  }, (files) => {
-    if (files) {
-      event.sender.send('selected-directory', files)
-    }
-  })
-})
-          
-        
- -
-

ProTip

- The sheet-style dialog on macOS. -

- On macOS you can choose between a "sheet" dialog or a default - dialog. The sheet version descends from the top of the window. To - use sheet version, pass the window as the first - argument in the dialog method. -

-
const ipc = require('electron').ipcMain
-const dialog = require('electron').dialog
-const BrowserWindow = require('electron').BrowserWindow
-
-
-ipc.on('open-file-dialog-sheet', function (event) {
-  const window = BrowserWindow.fromWebContents(event.sender)
-  const files = dialog.showOpenDialog(window, { properties: [ 'openFile' ]})
-})
-
-
-
-
- - - - + + + + + Open File or Directory + + + +
+

Use system dialogs

+ +

+ The dialog module in Electron allows you to use native + system dialogs for opening files or directories, saving a file or + displaying informational messages. +

+ +

+ This is a main process module because this process is more efficient + with native utilities and it allows the call to happen without + interrupting the visible elements in your page's renderer process. +

+ +

+ Open the + + full API documentation (opens in new window) + + in your browser. +

+
+ +
+
+

Open a File or Directory

+
+
+ + +
+

+ In this demo, the ipc module is used to send a message + from the renderer process instructing the main process to launch the + open file (or directory) dialog. If a file is selected, the main + process can send that information back to the renderer process. +

+
Renderer Process
+
+          
+const {ipcRenderer} = require('electron')
+
+const selectDirBtn = document.getElementById('select-directory')
+
+selectDirBtn.addEventListener('click', (event) => {
+  ipcRenderer.send('open-file-dialog')
+})
+
+ipcRenderer.on('selected-directory', (event, path) => {
+  document.getElementById('selected-file').innerHTML = `You selected: ${path}`
+})
+          
+        
+
Main Process
+
+          
+const {ipcMain, dialog} = require('electron')
+
+ipcMain.on('open-file-dialog', (event) => {
+  dialog.showOpenDialog({
+    properties: ['openFile', 'openDirectory']
+  }, (files) => {
+    if (files) {
+      event.sender.send('selected-directory', files)
+    }
+  })
+})
+          
+        
+ +
+

ProTip

+ The sheet-style dialog on macOS. +

+ On macOS you can choose between a "sheet" dialog or a default + dialog. The sheet version descends from the top of the window. To + use sheet version, pass the window as the first + argument in the dialog method. +

+
const ipc = require('electron').ipcMain
+const dialog = require('electron').dialog
+const BrowserWindow = require('electron').BrowserWindow
+
+
+ipc.on('open-file-dialog-sheet', function (event) {
+  const window = BrowserWindow.fromWebContents(event.sender)
+  const files = dialog.showOpenDialog(window, { properties: [ 'openFile' ]})
+})
+
+
+
+
+ + + + diff --git a/docs/fiddles/native-ui/dialogs/save-dialog/index.html b/docs/fiddles/native-ui/dialogs/save-dialog/index.html index b7ceaee7b1..cd6b0ad4cc 100644 --- a/docs/fiddles/native-ui/dialogs/save-dialog/index.html +++ b/docs/fiddles/native-ui/dialogs/save-dialog/index.html @@ -1,91 +1,91 @@ - - - - - Save Dialog - - - -
-

Use system dialogs

- -

- The dialog module in Electron allows you to use native - system dialogs for opening files or directories, saving a file or - displaying informational messages. -

- -

- This is a main process module because this process is more efficient - with native utilities and it allows the call to happen without - interrupting the visible elements in your page's renderer process. -

- -

- Open the - - full API documentation (opens in new window) - - in your browser. -

-
- -
-
-

Save Dialog

-
-
- - -
-

- In this demo, the ipc module is used to send a message - from the renderer process instructing the main process to launch the - save dialog. It returns the path selected by the user which can be - relayed back to the renderer process. -

-
Renderer Process
-
-            
-const {ipcRenderer} = require('electron')
-
-const saveBtn = document.getElementById('save-dialog')
-
-saveBtn.addEventListener('click', (event) => {
-  ipcRenderer.send('save-dialog')
-})
-
-ipcRenderer.on('saved-file', (event, path) => {
-  if (!path) path = 'No path'
-  document.getElementById('file-saved').innerHTML = `Path selected: ${path}`
-})
-            
-          
-
Main Process
-
-            
-const {ipcMain, dialog} = require('electron')
-
-ipcMain.on('save-dialog', (event) => {
-  const options = {
-    title: 'Save an Image',
-    filters: [
-      { name: 'Images', extensions: ['jpg', 'png', 'gif'] }
-    ]
-  }
-  dialog.showSaveDialog(options, (filename) => {
-    event.sender.send('saved-file', filename)
-  })
-})
-            
-          
-
-
-
- - - - + + + + + Save Dialog + + + +
+

Use system dialogs

+ +

+ The dialog module in Electron allows you to use native + system dialogs for opening files or directories, saving a file or + displaying informational messages. +

+ +

+ This is a main process module because this process is more efficient + with native utilities and it allows the call to happen without + interrupting the visible elements in your page's renderer process. +

+ +

+ Open the + + full API documentation (opens in new window) + + in your browser. +

+
+ +
+
+

Save Dialog

+
+
+ + +
+

+ In this demo, the ipc module is used to send a message + from the renderer process instructing the main process to launch the + save dialog. It returns the path selected by the user which can be + relayed back to the renderer process. +

+
Renderer Process
+
+            
+const {ipcRenderer} = require('electron')
+
+const saveBtn = document.getElementById('save-dialog')
+
+saveBtn.addEventListener('click', (event) => {
+  ipcRenderer.send('save-dialog')
+})
+
+ipcRenderer.on('saved-file', (event, path) => {
+  if (!path) path = 'No path'
+  document.getElementById('file-saved').innerHTML = `Path selected: ${path}`
+})
+            
+          
+
Main Process
+
+            
+const {ipcMain, dialog} = require('electron')
+
+ipcMain.on('save-dialog', (event) => {
+  const options = {
+    title: 'Save an Image',
+    filters: [
+      { name: 'Images', extensions: ['jpg', 'png', 'gif'] }
+    ]
+  }
+  dialog.showSaveDialog(options, (filename) => {
+    event.sender.send('saved-file', filename)
+  })
+})
+            
+          
+
+
+
+ + + + diff --git a/docs/fiddles/native-ui/drag-and-drop/index.html b/docs/fiddles/native-ui/drag-and-drop/index.html index 40f2733cd2..53aee6ddfc 100644 --- a/docs/fiddles/native-ui/drag-and-drop/index.html +++ b/docs/fiddles/native-ui/drag-and-drop/index.html @@ -1,76 +1,76 @@ - - - - - Drag and drop files - - - -
-

Drag and drop files

-
Supports: Win, macOS, Linux | Process: Both
-

- Electron supports dragging files and content out from web content into - the operating system's world. -

- -

- Open the - - full API documentation (opens in new window) - - in your browser. -

-
- -
-
-

Dragging files

-
-
- Drag Demo -
-

- Click and drag the link above to copy the renderer process - javascript file on to your machine. -

- -

- In this demo, the webContents.startDrag() API is called - in response to the ondragstart event. -

-
Renderer Process
-

-const {ipcRenderer} = require('electron')
-
-const dragFileLink = document.getElementById('drag-file-link')
-
-dragFileLink.addEventListener('dragstart', (event) => {
-  event.preventDefault()
-  ipcRenderer.send('ondragstart', __filename)
-})
-        
-
Main Process
-
-            
-const {ipcMain} = require('electron')
-const path = require('path')
-
-ipcMain.on('ondragstart', (event, filepath) => {
-  const iconName = 'codeIcon.png'
-  event.sender.startDrag({
-    file: filepath,
-    icon: path.join(__dirname, iconName)
-  })
-})
-            
-
-
-
- - - - + + + + + Drag and drop files + + + +
+

Drag and drop files

+
Supports: Win, macOS, Linux | Process: Both
+

+ Electron supports dragging files and content out from web content into + the operating system's world. +

+ +

+ Open the + + full API documentation (opens in new window) + + in your browser. +

+
+ +
+
+

Dragging files

+
+
+ Drag Demo +
+

+ Click and drag the link above to copy the renderer process + javascript file on to your machine. +

+ +

+ In this demo, the webContents.startDrag() API is called + in response to the ondragstart event. +

+
Renderer Process
+

+const {ipcRenderer} = require('electron')
+
+const dragFileLink = document.getElementById('drag-file-link')
+
+dragFileLink.addEventListener('dragstart', (event) => {
+  event.preventDefault()
+  ipcRenderer.send('ondragstart', __filename)
+})
+        
+
Main Process
+
+            
+const {ipcMain} = require('electron')
+const path = require('path')
+
+ipcMain.on('ondragstart', (event, filepath) => {
+  const iconName = 'codeIcon.png'
+  event.sender.startDrag({
+    file: filepath,
+    icon: path.join(__dirname, iconName)
+  })
+})
+            
+
+
+
+ + + + diff --git a/docs/fiddles/native-ui/external-links-file-manager/index.html b/docs/fiddles/native-ui/external-links-file-manager/index.html index c9e9e6f849..b8e496e149 100644 --- a/docs/fiddles/native-ui/external-links-file-manager/index.html +++ b/docs/fiddles/native-ui/external-links-file-manager/index.html @@ -1,104 +1,104 @@ - - - - - Open external links and the file manager - - -
-

- Open external links and the file manager -

-

- The shell module in Electron allows you to access certain - native elements like the file manager and default web browser. -

- -

This module works in both the main and renderer process.

-

- Open the - - full API documentation (opens in new window) - - in your browser. -

-
- -
-
-

Open Path in File Manager

-
-
- -
-

- This demonstrates using the shell module to open the - system file manager at a particular location. -

-

- Clicking the demo button will open your file manager at the root. -

-
-
-
- -
-
-

Open External Links

-
-
- -
-

- If you do not want your app to open website links - within the app, you can use the shell module - to open them externally. When clicked, the links will open outside - of your app and in the user's default web browser. -

-

- When the demo button is clicked, the electron website will open in - your browser. -

-

- -
-

ProTip

- Open all outbound links externally. -

- You may want to open all http and - https links outside of your app. To do this, query - the document and loop through each link and add a listener. This - app uses the code below which is located in - assets/ex-links.js. -

-
Renderer Process
-
-                
-const shell = require('electron').shell
-
-const links = document.querySelectorAll('a[href]')
-
-Array.prototype.forEach.call(links, (link) => {
-  const url = link.getAttribute('href')
-  if (url.indexOf('http') === 0) {
-    link.addEventListener('click', (e) => {
-      e.preventDefault()
-      shell.openExternal(url)
-    })
-  }
-})
-                
-              
-
-
-
-
- - - - + + + + + Open external links and the file manager + + +
+

+ Open external links and the file manager +

+

+ The shell module in Electron allows you to access certain + native elements like the file manager and default web browser. +

+ +

This module works in both the main and renderer process.

+

+ Open the + + full API documentation (opens in new window) + + in your browser. +

+
+ +
+
+

Open Path in File Manager

+
+
+ +
+

+ This demonstrates using the shell module to open the + system file manager at a particular location. +

+

+ Clicking the demo button will open your file manager at the root. +

+
+
+
+ +
+
+

Open External Links

+
+
+ +
+

+ If you do not want your app to open website links + within the app, you can use the shell module + to open them externally. When clicked, the links will open outside + of your app and in the user's default web browser. +

+

+ When the demo button is clicked, the electron website will open in + your browser. +

+

+ +
+

ProTip

+ Open all outbound links externally. +

+ You may want to open all http and + https links outside of your app. To do this, query + the document and loop through each link and add a listener. This + app uses the code below which is located in + assets/ex-links.js. +

+
Renderer Process
+
+                
+const shell = require('electron').shell
+
+const links = document.querySelectorAll('a[href]')
+
+Array.prototype.forEach.call(links, (link) => {
+  const url = link.getAttribute('href')
+  if (url.indexOf('http') === 0) {
+    link.addEventListener('click', (e) => {
+      e.preventDefault()
+      shell.openExternal(url)
+    })
+  }
+})
+                
+              
+
+
+
+
+ + + + diff --git a/docs/fiddles/native-ui/notifications/index.html b/docs/fiddles/native-ui/notifications/index.html index 99b8633fe4..60d43d1948 100644 --- a/docs/fiddles/native-ui/notifications/index.html +++ b/docs/fiddles/native-ui/notifications/index.html @@ -1,67 +1,67 @@ - - - - - Desktop notifications - - -
-

Desktop notifications

-

- The notification module in Electron allows you to add basic - desktop notifications. -

- -

- Electron conveniently allows developers to send notifications with the - HTML5 Notification API, - using the currently running operating system’s native notification - APIs to display it. -

- -

- Note: Since this is an HTML5 API it is only available in the - renderer process. -

- -

- Open the - - full API documentation(opens in new window) - - in your browser. -

-
- -
-
-

Basic notification

-
-
- -
-

This demo demonstrates a basic notification. Text only.

-
-
-
- -
-
-

Notification with image

-
-
- -
-

- This demo demonstrates a basic notification. Both text and a image -

-
-
-
- - - - + + + + + Desktop notifications + + +
+

Desktop notifications

+

+ The notification module in Electron allows you to add basic + desktop notifications. +

+ +

+ Electron conveniently allows developers to send notifications with the + HTML5 Notification API, + using the currently running operating system’s native notification + APIs to display it. +

+ +

+ Note: Since this is an HTML5 API it is only available in the + renderer process. +

+ +

+ Open the + + full API documentation(opens in new window) + + in your browser. +

+
+ +
+
+

Basic notification

+
+
+ +
+

This demo demonstrates a basic notification. Text only.

+
+
+
+ +
+
+

Notification with image

+
+
+ +
+

+ This demo demonstrates a basic notification. Both text and a image +

+
+
+
+ + + + diff --git a/docs/fiddles/native-ui/tray/index.html b/docs/fiddles/native-ui/tray/index.html index 81a25e1a86..482abeeab8 100644 --- a/docs/fiddles/native-ui/tray/index.html +++ b/docs/fiddles/native-ui/tray/index.html @@ -1,47 +1,47 @@ - - - - - Tray - - -
-

Tray

-

- The tray module allows you to create an icon in the - operating system's notification area. -

-

This icon can also have a context menu attached.

- -

- Open the - - full API documentation - - in your browser. -

-
-
-
-

ProTip

- Tray support in Linux. -

- On Linux distributions that only have app indicator support, users - will need to install libappindicator1 to make the - tray icon work. See the - - full API documentation - - for more details about using Tray on Linux. -

-
-
- - - - - - + + + + + Tray + + +
+

Tray

+

+ The tray module allows you to create an icon in the + operating system's notification area. +

+

This icon can also have a context menu attached.

+ +

+ Open the + + full API documentation + + in your browser. +

+
+
+
+

ProTip

+ Tray support in Linux. +

+ On Linux distributions that only have app indicator support, users + will need to install libappindicator1 to make the + tray icon work. See the + + full API documentation + + for more details about using Tray on Linux. +

+
+
+ + + + + + diff --git a/docs/fiddles/windows/manage-windows/frameless-window/index.html b/docs/fiddles/windows/manage-windows/frameless-window/index.html index 58179e2e81..78895119dc 100644 --- a/docs/fiddles/windows/manage-windows/frameless-window/index.html +++ b/docs/fiddles/windows/manage-windows/frameless-window/index.html @@ -1,77 +1,77 @@ - - - - - Frameless window - - - -
-

Create and Manage Windows

- -

- The BrowserWindow module in Electron allows you to create a - new browser window or manage an existing one. -

- -

- Each browser window is a separate process, known as the renderer - process. This process, like the main process that controls the life - cycle of the app, has full access to the Node.js APIs. -

- -

- Open the - - full API documentation (opens in new window) - - in your browser. -

-
- -
-
-

Create a frameless window

-
-
- -
-

- A frameless window is a window that has no - - "chrome" - - , such as toolbars, title bars, status bars, borders, etc. You can - make a browser window frameless by setting frame to - false when creating the window. -

- -

- Windows can have a transparent background, too. By setting the - transparent option to true, you can also - make your frameless window transparent: -

-
-var win = new BrowserWindow({
-  transparent: true,
-  frame: false
-})
- -

- For more details, see the - - Window Customization - - - documentation. -

-
-
-
- - - - + + + + + Frameless window + + + +
+

Create and Manage Windows

+ +

+ The BrowserWindow module in Electron allows you to create a + new browser window or manage an existing one. +

+ +

+ Each browser window is a separate process, known as the renderer + process. This process, like the main process that controls the life + cycle of the app, has full access to the Node.js APIs. +

+ +

+ Open the + + full API documentation (opens in new window) + + in your browser. +

+
+ +
+
+

Create a frameless window

+
+
+ +
+

+ A frameless window is a window that has no + + "chrome" + + , such as toolbars, title bars, status bars, borders, etc. You can + make a browser window frameless by setting frame to + false when creating the window. +

+ +

+ Windows can have a transparent background, too. By setting the + transparent option to true, you can also + make your frameless window transparent: +

+
+var win = new BrowserWindow({
+  transparent: true,
+  frame: false
+})
+ +

+ For more details, see the + + Window Customization + + + documentation. +

+
+
+
+ + + + diff --git a/docs/fiddles/windows/manage-windows/manage-window-state/index.html b/docs/fiddles/windows/manage-windows/manage-window-state/index.html index e9e39ceccc..3521dd66ac 100644 --- a/docs/fiddles/windows/manage-windows/manage-window-state/index.html +++ b/docs/fiddles/windows/manage-windows/manage-window-state/index.html @@ -1,64 +1,64 @@ - - - - - Manage window state - - - -
-

Create and Manage Windows

- -

- The BrowserWindow module in Electron allows you to create a - new browser window or manage an existing one. -

- -

- Each browser window is a separate process, known as the renderer - process. This process, like the main process that controls the life - cycle of the app, has full access to the Node.js APIs. -

- -

- Open the - - full API documentation (opens in new window) - - in your browser. -

-
- -
-
-

Manage window state

-
-
- - -
-

- In this demo we create a new window and listen for - move and resize events on it. Click the - demo button, change the new window and see the dimensions and - position update here, above. -

-

- There are a lot of methods for controlling the state of the window - such as the size, location, and focus status as well as events to - listen to for window changes. Visit the - - documentation (opens in new window) - - for the full list. -

-
-
-
- - - - + + + + + Manage window state + + + +
+

Create and Manage Windows

+ +

+ The BrowserWindow module in Electron allows you to create a + new browser window or manage an existing one. +

+ +

+ Each browser window is a separate process, known as the renderer + process. This process, like the main process that controls the life + cycle of the app, has full access to the Node.js APIs. +

+ +

+ Open the + + full API documentation (opens in new window) + + in your browser. +

+
+ +
+
+

Manage window state

+
+
+ + +
+

+ In this demo we create a new window and listen for + move and resize events on it. Click the + demo button, change the new window and see the dimensions and + position update here, above. +

+

+ There are a lot of methods for controlling the state of the window + such as the size, location, and focus status as well as events to + listen to for window changes. Visit the + + documentation (opens in new window) + + for the full list. +

+
+
+
+ + + + diff --git a/docs/fiddles/windows/manage-windows/window-events/index.html b/docs/fiddles/windows/manage-windows/window-events/index.html index d244bf1675..b89dca080c 100644 --- a/docs/fiddles/windows/manage-windows/window-events/index.html +++ b/docs/fiddles/windows/manage-windows/window-events/index.html @@ -1,58 +1,58 @@ - - - - - Window events - - - -
-

Create and Manage Windows

- -

- The BrowserWindow module in Electron allows you to create a - new browser window or manage an existing one. -

- -

- Each browser window is a separate process, known as the renderer - process. This process, like the main process that controls the life - cycle of the app, has full access to the Node.js APIs. -

- -

- Open the - - full API documentation (opens in new window) - - in your browser. -

-
- -
-
-

Window events

-
-
- - -
-

- In this demo, we create a new window and listen for - blur event on it. Click the demo button to create a new - modal window, and switch focus back to the parent window by clicking - on it. You can click the Focus on Demo button to switch focus - to the modal window again. -

-
-
-
- - - - + + + + + Window events + + + +
+

Create and Manage Windows

+ +

+ The BrowserWindow module in Electron allows you to create a + new browser window or manage an existing one. +

+ +

+ Each browser window is a separate process, known as the renderer + process. This process, like the main process that controls the life + cycle of the app, has full access to the Node.js APIs. +

+ +

+ Open the + + full API documentation (opens in new window) + + in your browser. +

+
+ +
+
+

Window events

+
+
+ + +
+

+ In this demo, we create a new window and listen for + blur event on it. Click the demo button to create a new + modal window, and switch focus back to the parent window by clicking + on it. You can click the Focus on Demo button to switch focus + to the modal window again. +

+
+
+
+ + + + diff --git a/spec/fixtures/api/frame-subscriber.html b/spec/fixtures/api/frame-subscriber.html index 0d5c7b3178..69ceb90d37 100644 --- a/spec/fixtures/api/frame-subscriber.html +++ b/spec/fixtures/api/frame-subscriber.html @@ -1,11 +1,11 @@ - - -
- - - + + +
+ + + diff --git a/spec/fixtures/api/offscreen-rendering.html b/spec/fixtures/api/offscreen-rendering.html index 8e61a75352..b144e96d73 100644 --- a/spec/fixtures/api/offscreen-rendering.html +++ b/spec/fixtures/api/offscreen-rendering.html @@ -1,11 +1,11 @@ - - -
- - - + + +
+ + + diff --git a/spec/fixtures/api/service-workers/index.html b/spec/fixtures/api/service-workers/index.html index bb90197451..81c54d201b 100644 --- a/spec/fixtures/api/service-workers/index.html +++ b/spec/fixtures/api/service-workers/index.html @@ -1,10 +1,10 @@ - - - - - + + + + + \ No newline at end of file diff --git a/spec/fixtures/api/service-workers/logs.html b/spec/fixtures/api/service-workers/logs.html index d61005f344..9627972c4b 100644 --- a/spec/fixtures/api/service-workers/logs.html +++ b/spec/fixtures/api/service-workers/logs.html @@ -1,10 +1,10 @@ - - - - - + + + + + \ No newline at end of file