I am trying to add functionality to a button in index.html
file is as follows:
I have a button element in index.html
<button id="auth-button">Authorize</button>
In main.js
of the app, I have
require('crash-reporter').start();
console.log("oh yaeh!");
var mainWindow = null;
app.on('window-all-closed', function(){
if(process.platform != 'darwin'){
app.quit();
}
});
app.on('ready',function(){
mainWindow = new BrowserWindow({width:800, height : 600});
mainWindow.loadUrl('file://' + __dirname + '/index.html');
var authButton = document.getElementById("auth-button");
authButton.addEventListener("click",function(){alert("clicked!");});
mainWindow.openDevTools();
mainWindow.on('closed',function(){
mainWindow = null;
});
});
But an error occurs as follows:
Uncaught Exception: ReferenceError: document is not defined
Can the DOM objects be accessed while building electron apps? or is there any other alternative way that can give me the required functionality?