Implement webContents.savePage API.

This commit is contained in:
Haojian Wu 2015-10-14 12:41:31 +08:00
parent ddea2fced4
commit facd0fbc08
8 changed files with 210 additions and 0 deletions

View file

@ -631,3 +631,26 @@ Get the `WebContents` of DevTools for this `WebContents`.
**Note:** Users should never store this object because it may become `null`
when the DevTools has been closed.
### `webContents.savePage(fullPath, saveType, callback)`
* `fullPath` String - The full file path.
* `saveType` String - Specify the save type.
* `HTMLOnly` - Save only the HTML of the page.
* `HTMLComplete` - Save complete-html page.
* `MHTML` - Save complete-html page as MHTML.
* `callback` Function - `function(error) {}`.
* `error` Error
Returns true if the process of saving page has been initiated successfully.
```javascript
win.loadUrl('https://github.com');
win.webContents.on('did-finish-load', function() {
win.webContents.savePage('/tmp/test.html', 'HTMLComplete', function(error) {
if (!error)
console.log("Save page successfully");
});
});
```