Merge pull request #8569 from electron/webview-default-node-integration
Mention presence of webview attributes enables them
This commit is contained in:
commit
555347e726
1 changed files with 26 additions and 20 deletions
|
@ -35,7 +35,7 @@ and displays a "loading..." message during the load time:
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
onload = () => {
|
onload = () => {
|
||||||
const webview = document.getElementById('foo')
|
const webview = document.querySelector('webview')
|
||||||
const indicator = document.querySelector('.indicator')
|
const indicator = document.querySelector('.indicator')
|
||||||
|
|
||||||
const loadstart = () => {
|
const loadstart = () => {
|
||||||
|
@ -103,14 +103,15 @@ The `src` attribute can also accept data URLs, such as
|
||||||
### `autosize`
|
### `autosize`
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<webview src="https://www.github.com/" autosize="on" minwidth="576" minheight="432"></webview>
|
<webview src="https://www.github.com/" autosize minwidth="576" minheight="432"></webview>
|
||||||
```
|
```
|
||||||
|
|
||||||
If "on", the `webview` container will automatically resize within the
|
When this attribute is present the `webview` container will automatically resize
|
||||||
bounds specified by the attributes `minwidth`, `minheight`, `maxwidth`, and
|
within the bounds specified by the attributes `minwidth`, `minheight`,
|
||||||
`maxheight`. These constraints do not impact the `webview` unless `autosize` is
|
`maxwidth`, and `maxheight`. These constraints do not impact the `webview`
|
||||||
enabled. When `autosize` is enabled, the `webview` container size cannot be less
|
unless `autosize` is enabled. When `autosize` is enabled, the `webview`
|
||||||
than the minimum values or greater than the maximum.
|
container size cannot be less than the minimum values or greater than the
|
||||||
|
maximum.
|
||||||
|
|
||||||
### `nodeintegration`
|
### `nodeintegration`
|
||||||
|
|
||||||
|
@ -118,8 +119,10 @@ than the minimum values or greater than the maximum.
|
||||||
<webview src="http://www.google.com/" nodeintegration></webview>
|
<webview src="http://www.google.com/" nodeintegration></webview>
|
||||||
```
|
```
|
||||||
|
|
||||||
If "on", the guest page in `webview` will have node integration and can use node
|
When this attribute is present the guest page in `webview` will have node
|
||||||
APIs like `require` and `process` to access low level system resources.
|
integration and can use node APIs like `require` and `process` to access low
|
||||||
|
level system resources. Node integration is disabled by default in the guest
|
||||||
|
page.
|
||||||
|
|
||||||
### `plugins`
|
### `plugins`
|
||||||
|
|
||||||
|
@ -127,7 +130,8 @@ APIs like `require` and `process` to access low level system resources.
|
||||||
<webview src="https://www.github.com/" plugins></webview>
|
<webview src="https://www.github.com/" plugins></webview>
|
||||||
```
|
```
|
||||||
|
|
||||||
If "on", the guest page in `webview` will be able to use browser plugins.
|
When this attribute is present the guest page in `webview` will be able to use
|
||||||
|
browser plugins. Plugins are disabled by default.
|
||||||
|
|
||||||
### `preload`
|
### `preload`
|
||||||
|
|
||||||
|
@ -166,7 +170,8 @@ page is loaded, use the `setUserAgent` method to change the user agent.
|
||||||
<webview src="https://www.github.com/" disablewebsecurity></webview>
|
<webview src="https://www.github.com/" disablewebsecurity></webview>
|
||||||
```
|
```
|
||||||
|
|
||||||
If "on", the guest page will have web security disabled.
|
When this attribute is present the guest page will have web security disabled.
|
||||||
|
Web security is enabled by default.
|
||||||
|
|
||||||
### `partition`
|
### `partition`
|
||||||
|
|
||||||
|
@ -192,7 +197,8 @@ value will fail with a DOM exception.
|
||||||
<webview src="https://www.github.com/" allowpopups></webview>
|
<webview src="https://www.github.com/" allowpopups></webview>
|
||||||
```
|
```
|
||||||
|
|
||||||
If "on", the guest page will be allowed to open new windows.
|
When this attribute is present the guest page will be allowed to open new
|
||||||
|
windows. Popups are disabled by default.
|
||||||
|
|
||||||
### `webpreferences`
|
### `webpreferences`
|
||||||
|
|
||||||
|
@ -249,8 +255,8 @@ webContents when a new url is loaded.
|
||||||
<webview src="https://www.github.com/" disableguestresize></webview>
|
<webview src="https://www.github.com/" disableguestresize></webview>
|
||||||
```
|
```
|
||||||
|
|
||||||
Prevents the webview contents from resizing when the webview element itself is
|
When this attribute is present the `webview` contents will be prevented from
|
||||||
resized.
|
resizing when the `webview` element itself is resized.
|
||||||
|
|
||||||
This can be used in combination with
|
This can be used in combination with
|
||||||
[`webContents.setSize`](web-contents.md#contentssetsizeoptions) to manually
|
[`webContents.setSize`](web-contents.md#contentssetsizeoptions) to manually
|
||||||
|
@ -290,7 +296,7 @@ The `webview` tag has the following methods:
|
||||||
**Example**
|
**Example**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const webview = document.getElementById('foo')
|
const webview = document.querySelector('webview')
|
||||||
webview.addEventListener('dom-ready', () => {
|
webview.addEventListener('dom-ready', () => {
|
||||||
webview.openDevTools()
|
webview.openDevTools()
|
||||||
})
|
})
|
||||||
|
@ -703,7 +709,7 @@ The following example code forwards all log messages to the embedder's console
|
||||||
without regard for log level or other properties.
|
without regard for log level or other properties.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const webview = document.getElementById('foo')
|
const webview = document.querySelector('webview')
|
||||||
webview.addEventListener('console-message', (e) => {
|
webview.addEventListener('console-message', (e) => {
|
||||||
console.log('Guest page logged a message:', e.message)
|
console.log('Guest page logged a message:', e.message)
|
||||||
})
|
})
|
||||||
|
@ -723,7 +729,7 @@ Fired when a result is available for
|
||||||
[`webview.findInPage`](webview-tag.md#webviewtagfindinpage) request.
|
[`webview.findInPage`](webview-tag.md#webviewtagfindinpage) request.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const webview = document.getElementById('foo')
|
const webview = document.querySelector('webview')
|
||||||
webview.addEventListener('found-in-page', (e) => {
|
webview.addEventListener('found-in-page', (e) => {
|
||||||
webview.stopFindInPage('keepSelection')
|
webview.stopFindInPage('keepSelection')
|
||||||
})
|
})
|
||||||
|
@ -749,7 +755,7 @@ The following example code opens the new url in system's default browser.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const {shell} = require('electron')
|
const {shell} = require('electron')
|
||||||
const webview = document.getElementById('foo')
|
const webview = document.querySelector('webview')
|
||||||
|
|
||||||
webview.addEventListener('new-window', (e) => {
|
webview.addEventListener('new-window', (e) => {
|
||||||
const protocol = require('url').parse(e.url).protocol
|
const protocol = require('url').parse(e.url).protocol
|
||||||
|
@ -810,7 +816,7 @@ The following example code navigates the `webview` to `about:blank` when the
|
||||||
guest attempts to close itself.
|
guest attempts to close itself.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const webview = document.getElementById('foo')
|
const webview = document.querySelector('webview')
|
||||||
webview.addEventListener('close', () => {
|
webview.addEventListener('close', () => {
|
||||||
webview.src = 'about:blank'
|
webview.src = 'about:blank'
|
||||||
})
|
})
|
||||||
|
@ -830,7 +836,7 @@ between guest page and embedder page:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// In embedder page.
|
// In embedder page.
|
||||||
const webview = document.getElementById('foo')
|
const webview = document.querySelector('webview')
|
||||||
webview.addEventListener('ipc-message', (event) => {
|
webview.addEventListener('ipc-message', (event) => {
|
||||||
console.log(event.channel)
|
console.log(event.channel)
|
||||||
// Prints "pong"
|
// Prints "pong"
|
||||||
|
|
Loading…
Reference in a new issue