Develop desktop app using html, css and javascript
Posted By : Md Imroz Alam | 27-Sep-2017
We can develop a desktop app using HTML CSS javascript. An electron is an
1) we need to setup electron globally to our system
npm install electron -g
Electron provides an
2) In this demo app, we are using directory structure as following:-
a) main.js :- it contain electron app startup code.
b) index.html:- it contain javascript, HTML and CSS code.
3) main.js content
function createWindow() {
var electron=require("electron");
var url = require('url');
var path = require('path');
var {
app,
BrowserWindow
} = electron;
var getUrl = url;
var getPath = path;
function initWindow() {
win = new BrowserWindow({
width: 800,
height: 600
})
win.loadURL(url.format({
pathname: getPath.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}));
win.on('closed', () => {
win = null
})
}
function quitApp() {
if (process.platform !== 'darwin') {
app.quit();
}
}
function activateWindow() {
if (win === null) {
createWindow()
}
}
app.on('ready', initWindow);
app.on('window-all-closed', quitApp);
app.on('activate', activateWindow);
}
var initApp = function() {
createWindow();
}
electron app has
4) index.html content
Welcome to desktop app
We are using Node.js, Chromium, and Electron.
5) To run this demo app
electron main.js
Thanks
To create packaging and build for electron demo app http://www.oodlestechnologies.com/blogs/Packaging-and-build-for-electron-app
I
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Md Imroz Alam
Md. Imroz Alam is a bright Web App Developer, he has good knowledge of Java, J2SE, Jsp, Servlet, jdbc. His hobbies are watching movie, playing carom.