最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I redirect to another page once an Electron app has started? - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question edited Feb 12, 2024 at 21:53 isherwood 61.1k16 gold badges120 silver badges168 bronze badges asked Nov 8, 2015 at 22:43 DanyDany 7551 gold badge9 silver badges27 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 16

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 then 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.html page. Electron works here exactly like a browser.

<a href="page.html">Go to page</a>
发布评论

评论列表(0)

  1. 暂无评论