index.js file
const {BrowserWindow, app, globalShortcut} = require('electron');
const url = require('url');
const si = require('systeminformation');
let win = null
function boot() {
//console.log(process.type)
win = new BrowserWindow({
width: 600,
height: 500,
frame: false
})
var output = document.getElementById("output");
output.innerHTML = "hello world"
//win.loadURL(file:'//${__dirname}/index.html')
win.loadURL('file://' + __dirname + '/index.html');
win.on('closed', () => {
win = null
})
}
app.on('ready', boot);
**index.html file **
<!DOCTYPE html>
<html lang= "en">
<head>
<meta charset="UTF-8">
<title>Hello World</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="content">
<header>
<div class="option" id="close">X</div>
<div class="option" id="minimize">-</div>
</header>
<div id="text">z</div>
<h1>
<p id="output"></p>
</h1>
</div>
<script src="./assets/js/script.js"></script>
</body>
</html>
So I am using the value from the following snippet to be display into my HTML page
var output = document.getElementById("output");
output.innerHTML = "hello world"
Through this on my HTML page:
<h1>
<p id="output"></p>
</h1>
But it gives me the error:
"reference error :document is not defined "
By the way I am creating an Electron app. Just trying to display some data from my javascript page to html page.