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
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "electron ." | |
}, |
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": "electron_code", | |
"version": "1.0.0", | |
"description": "Electron.js practice code", | |
"main": "main.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "electron ." | |
}, | |
"keywords": [ |
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
const { app, BrowserWindow } = require('electron'); | |
let mainWindow; | |
app.on('ready', () => { | |
mainWindow = new BrowserWindow({ | |
width: 1536, | |
height: 900, | |
frame: true, | |
webPreferences: { |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<script> | |
window.nodeRequire = require; | |
delete window.require; | |
delete window.exports; | |
delete window.module; | |
</script> | |
<meta charset="UTF-8"> |
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
<p id="content_styler"> | |
Electron enables you to create desktop applications with pure JavaScript by providing a runtime with rich native (operating system) APIs. You could see it as a variant of the Node.js runtime that is focused on desktop applications instead of web servers. | |
</p> | |
<button id="activate_button" onclick="performFunction()">Click Me!</button> | |
<script> | |
function performFunction() { | |
var p = document.getElementById("content_styler"); | |
p.innerHTML = "I am the changed text"; | |
} | |
</script> |
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
let mainWindow; | |
app.on('ready', () => { | |
mainWindow = new BrowserWindow({ | |
width: 1536, | |
height: 900, | |
frame: true, | |
webPreferences: { | |
nodeIntegration: true | |
} | |
}); |
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
const ipcRenderer = require('electron').ipcRenderer; | |
const btnclick = document.getElementById('activate_button'); | |
btnclick.addEventListener('click', function() { | |
var arg = "secondparam"; | |
ipcRenderer.send("btnclick", arg); // ipcRender.send will pass the information to main process | |
}); |
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
const { app, BrowserWindow, ipcMain } = require('electron'); | |
//ipcMain.on will receive the “btnclick” info from renderprocess | |
ipcMain.on("btnclick", function(event, arg) { | |
var url = "https://www.google.com"; | |
// inform the render process that the assigned task finished. | |
// event.sender.send in ipcMain will return the reply to renderprocess | |
event.sender.send("btnclick-task-finished", url); | |
}); |