0

I am making an Electron app that when a button is clicked it creates a new window and loads HTML into it, but for some reason the HTML isn't loaded into it and when I toggle developer tools for the window it shows me in the console this error:

"Not allowed to load local resource". It doesn't tell me a specific line.

const electron = require('electron');
const {ipcRenderer} = electron;
const {BrowserWindow} = electron.remote;

// NewTODO window variable
let newTodoWindow;

// Function to call when "New todo" button is clicked
function NewTodo(){
  // Creates a NewTODO window
  createTodoWindow();
}

function createTodoWindow(){
  newTodoWindow = new BrowserWindow({});
  newTodoWindow.loadFile("./newTodoWindow.html");
  newTodoWindow.setSize(400 , 400);
}

All it needs to do is that when createTodoWindow function is called(And it is called) it would create a new window and load the HTML to it, but it only creates the window without loading the HTML. I am not sure why that goes like and I would really appreciate getting help.

Tal Moshel
  • 232
  • 3
  • 18
  • 1
    If you get console errors, it's a good idea not to paraphrase them, but to show them verbatim (just copy-paste them, and then put them in your post the same way you put a block of code), and explain which line number maps to which line of code you're showing in your post. – Mike 'Pomax' Kamermans Dec 26 '18 at 17:31
  • Possible duplicate of [Electron - Not allowed to load local resource](https://stackoverflow.com/questions/41130993/electron-not-allowed-to-load-local-resource) – SanSolo Dec 27 '18 at 05:55

1 Answers1

0

So apparently this error occurs when trying to require a file that doesn't exist and that's exactly what I tried doing, For some reason I changed the file I tried requiring and just forgot to require the file with the right name.

Tal Moshel
  • 232
  • 3
  • 18