How to display value from a Javascript function onto an HTML page? -


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 using value following snippet display html page

var output = document.getelementbyid("output"); output.innerhtml = "hello world" 

through on html page:

<h1>   <p id="output"></p> </h1> 

but gives me error:

"reference error :document not defined "

by way creating electron app. trying display data javascript page html page.

as per code provided, referring document before gets loaded.

var output = document.getelementbyid("output"); // <- here , output.innerhtml = "hello world"; win.loadurl('file://' + __dirname + '/index.html'); // <- here 

check if dom ready before manipulating it.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -