Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Electron app. Multiple html files

I have an electron app with multiple html files in the root directory.

  • index.html
  • page1.html
  • page.html

I cannot find a way to redirect from index.html to page1.html once Electro has started.

Does anyone know how to do this?

like image 738
Dany Avatar asked Nov 08 '15 22:11

Dany


1 Answers

When your first page is index.html you call that page, when you create your window.

const win = new BrowserWindow(options);
win.loadUrl(`file://${__dirname}/index.html`);

If you want to load another page maybe

win.loadUrl(`file://${__dirname}/page.html`);

could help you.

If the page should be loaded after a user action (e.g. click on a link). You can add the link to your index.hmtl page. Electron works here exactly like a browser.

<a href="page.html">Go to page</a>
like image 88
apxp Avatar answered Sep 18 '22 10:09

apxp