Created
October 15, 2017 03:55
-
-
Save lamarmarshall/9b25b6daf33c33a8e8bb83186472a1ea to your computer and use it in GitHub Desktop.
electron open new window
This file contains hidden or 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
const remote = require('electron').remote | |
const main = remote.require('./index.js') | |
var buttton = document.getElementById("btn") | |
buttton.addEventListener('click', () => { | |
main.openWindow("pagetwo") | |
}) | |
document.body.appendChild(button) |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
</head> | |
<body> | |
<h1>hello world</h1> | |
<button id="btn">open window</button> | |
<script src="home.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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
const electron = require('electron') | |
const {app, BrowserWindow} = electron | |
app.on('ready', () => { | |
let win = new BrowserWindow({width:800, height: 600 }) | |
win.loadURL('file://'+ __dirname+'/index.html') | |
}) | |
exports.openWindow = (filename) =>{ | |
//win.currentOpenWindow().close() | |
let win = new BrowserWindow({width: 400, height: 400}) | |
win.loadURL('file:/'+__dirname+'/'+filename+'.html') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment