Created
November 13, 2015 20:45
-
-
Save rprichard/5aed5b96e69cc22b66b8 to your computer and use it in GitHub Desktop.
Crash Electron even with event.preventDefault
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var BrowserWindow = require("browser-window"); | |
var app = require("app"); | |
var request = require('request'); | |
app.on("ready", function() { | |
var dummyWindow = new BrowserWindow({ | |
title: "Parent", | |
show: true, | |
}); | |
var w = new BrowserWindow({ | |
title: "Child", | |
show: true, | |
}); | |
w.on("page-title-updated", function(event) { | |
event.preventDefault(); | |
var newTitle = w.webContents.getTitle(); | |
console.log("page-title-updated: title=" + newTitle); | |
w.close(); | |
request('http://www.google.com', function (error, response, body) { | |
if (!error && response.statusCode == 200) { | |
console.log(body) // Show the HTML for the Google homepage. | |
} | |
}) | |
console.log("page-title-updated: returning"); | |
}); | |
w.on("close", function() { | |
console.log("close"); | |
}); | |
w.on("closed", function() { | |
console.log("closed"); | |
}); | |
w.loadUrl("file://" + __dirname + "/main1.html"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head><script>window.location = "main2.html";</script></head></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head><title>main2</title></head></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "CloseHandlingCrash", | |
"productName": "CloseHandlingCrash", | |
"version": "0.1.0", | |
"main": "main.js", | |
"dependencies": { | |
"request": "2.65.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment