0

I am new to electron and other front-end technologies. I am trying to implement a desktop app using electron. In this app on clicking a button a new window should open. The main window is opening correctly but on clicking the button nothing happens. I am unable to find the error .I hope someone can help. Thanks in advance :)

<!DOCTYPE html>
<html>
   <head>
      <meta charset = "UTF-8">
      <title>Hello World!</title>
      <link rel="stylesheet" href="../assets/css/index.css">
   </head>
   
   <body>
      <button id="addAlias" class="buttons">Add Alias</button>
      <button id="generateKey" class="buttons">Generate Keys</button>
      <button id="balance" class="buttons">Check Balance</button>
      <button id="transaction" class="buttons">Send Money</button>
      <script>
         const button = document.getElementById('addAlias');
         button.addEventListener('click', () => {
            createBrowserWindow();
         });

         function createBrowserWindow() {
            const remote = require('electron').remote;
            const BrowserWindow = remote.BrowserWindow;
            const win = new BrowserWindow({
               height: 600,
               width: 800
            });
            win.loadURL('https://stackoverflow.com/questions/53390798/opening-new-window-electron');
            win.once('ready-to-show', () => {
               win.show()
            })
         }
      </script>      
   </body>
</html>

enter image description here

1 Answers1

0

When I use your code, the console logs the error : Uncaught ReferenceError: require is not defined

Maybe you'll find the solution on this thread : Electron require() is not defined