Skip to content

Instantly share code, notes, and snippets.

@wmatyjewicz
Created May 16, 2016 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmatyjewicz/1fc71fcfc3ff49ff503a77f50d97a449 to your computer and use it in GitHub Desktop.
Save wmatyjewicz/1fc71fcfc3ff49ff503a77f50d97a449 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>children-beforeunload</title>
</head>
<body>
<a href="about:blank" target="_blank">Child</a>
</body>
</html>
(function() {
const electron = require('electron');
const remote = electron.remote;
const dialog = remote.dialog;
window.onbeforeunload = function(ev) {
dialog.showErrorBox('beforeunload', 'beforeunload');
ev.returnValue = true;
};
}());
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
let mainWindow = null;
function createMainWindow() {
mainWindow = new BrowserWindow({
title: 'children-beforeunload', width: 800, height: 600,
webPreferences: {
preload: path.resolve(__dirname, 'inject.js'),
nodeIntegration: false
}
});
mainWindow.loadURL('file://' + __dirname + '/index.html');
mainWindow.on('closed', () => {
mainWindow = null;
});
}
app.on('ready', createMainWindow);
app.on('window-all-closed', () => {
app.quit();
});
{
"name": "children-beforeunload",
"version": "0.0.1",
"main": "main.js",
"dependencies": {
"electron-prebuilt": "^1.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment