From: Cheng Zhao Date: Tue, 1 Sep 2015 12:16:28 +0000 (+0800) Subject: docs: Small changes to will-download event X-Git-Tag: v0.31.2~6 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0cb20c48f6fa91131201f327da6d992599802c59;p=electron.git docs: Small changes to will-download event --- diff --git a/docs/api/session.md b/docs/api/session.md index 28a0c92c..439cf851 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -18,20 +18,21 @@ var session = win.webContents.session ### Event: 'will-download' * `event` Event -* `downloadItem` Object +* `item` Object * `url` String * `filename` String * `mimeType` String * `hasUserGesture` Boolean -* `webContents` (WebContents)[web-contents.md] +* `webContents` [WebContents](web-contents.md) -Fired when a download is about to start. Calling `preventDefault()` -will cancel the download. +Fired when Electron is about to download `item` in `webContents`. + +Calling `event.preventDefault()` will cancel the download. ```javascript -session.on('will-download', function(e, downloadItem, webContents) { - e.preventDefault(); - require('request')(downloadItem.url, function(data) { +session.on('will-download', function(event, item, webContents) { + event.preventDefault(); + require('request')(item.url, function(data) { require('fs').writeFileSync('/somewhere', data); }); });