Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Created October 15, 2017 03:55
Show Gist options
  • Save lamarmarshall/9b25b6daf33c33a8e8bb83186472a1ea to your computer and use it in GitHub Desktop.
Save lamarmarshall/9b25b6daf33c33a8e8bb83186472a1ea to your computer and use it in GitHub Desktop.
electron open new window
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)
<!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>
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