docs: Small changes to will-download event
This commit is contained in:
parent
4e7f56846f
commit
0cb20c48f6
1 changed files with 8 additions and 7 deletions
|
@ -18,20 +18,21 @@ var session = win.webContents.session
|
||||||
### Event: 'will-download'
|
### Event: 'will-download'
|
||||||
|
|
||||||
* `event` Event
|
* `event` Event
|
||||||
* `downloadItem` Object
|
* `item` Object
|
||||||
* `url` String
|
* `url` String
|
||||||
* `filename` String
|
* `filename` String
|
||||||
* `mimeType` String
|
* `mimeType` String
|
||||||
* `hasUserGesture` Boolean
|
* `hasUserGesture` Boolean
|
||||||
* `webContents` (WebContents)[web-contents.md]
|
* `webContents` [WebContents](web-contents.md)
|
||||||
|
|
||||||
Fired when a download is about to start. Calling `preventDefault()`
|
Fired when Electron is about to download `item` in `webContents`.
|
||||||
will cancel the download.
|
|
||||||
|
Calling `event.preventDefault()` will cancel the download.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
session.on('will-download', function(e, downloadItem, webContents) {
|
session.on('will-download', function(event, item, webContents) {
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
require('request')(downloadItem.url, function(data) {
|
require('request')(item.url, function(data) {
|
||||||
require('fs').writeFileSync('/somewhere', data);
|
require('fs').writeFileSync('/somewhere', data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue