-
-
Save redanium/356ee014b8dac8c6bf761c5a7d591809 to your computer and use it in GitHub Desktop.
Create Electron's BrowserWindow with dynamic HTML content
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
// main.js for Electron | |
var app = require("app"), | |
BrowserWindow = require("browser-window"); | |
app.on("window-all-closed", function() { | |
app.quit(); | |
}) | |
var mainWindow = null; | |
app.on("ready", function() { | |
mainWindow = new BrowserWindow({ | |
width: 800, | |
height: 600, | |
center: true, | |
resizable: true, | |
frame: true, | |
transparent: false, | |
}); | |
mainWindow.setMenu(null); | |
// create BrowserWindow with dynamic HTML content | |
var html = [ | |
"<body>", | |
"<h1>It works</h1>", | |
"</body>", | |
].join(""); | |
mainWindow.loadUrl("data:text/html;charset=utf-8," + encodeURI(html)); | |
mainWindow.openDevTools(); | |
mainWindow.on("closed", function() { | |
mainWindow = null; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment