From 4e1943dfe63411c0338f8177c613f375087fdf50 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 11 May 2017 09:01:51 -0700 Subject: [PATCH] Minor updates to example * const-ing * mainWindow -> win * add dialog require --- docs/api/web-contents.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index d2d3567f141a..1d7b9d5e193a 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -230,10 +230,10 @@ Calling `event.preventDefault()` will ignore the `beforeunload` event handler and allow the page to be unloaded. ```javascript -const {BrowserWindow} = require('electron') -let win = new BrowserWindow({width: 800, height: 600}) +const {BrowserWindow, dialog} = require('electron') +const win = new BrowserWindow({width: 800, height: 600}) win.webContents.on('will-prevent-unload', (event) => { - let choice = dialog.showMessageBox(mainWindow, { + const choice = dialog.showMessageBox(win, { type: 'question', buttons: ['Leave', 'Stay'], title: 'Do you want to leave this site?', @@ -241,7 +241,7 @@ win.webContents.on('will-prevent-unload', (event) => { defaultId: 0, cancelId: 1 }) - let leave = (choice === 0) + const leave = (choice === 0) if (leave) { event.preventDefault() }