Navigating between pages in the Electron app

In Electron, what is the standard way to navigate different pages / locations when clicking a link?

I tried to create

<a href="/profile.html>profile</a> 

and an HTML file called profile.html, but clicking the link just takes my application to a blank page.

What actually happens when a link is clicked and what is the right way to make basic links?

+7
electron
source share
3 answers

Just use a relative link - this will work (note the slash at the beginning):

 <a href="profile.html">profile</a> 

This is because Electron uses local file:// URLs that map to your file system. If you link to /profile.html , which will look for the file in the root directory of your drive, and you probably want it to download the file from the same directory.

Also, if you place the profile.html file in the directory with page names, you can access it as follows:

 <a href="pages/profile.html">profile</a> 
+12
source share

Electron is designed to work best with a single-page application . Clicking on a link should not load a new page, but should manipulate the DOM to change the contents on the same page.

If you use jquery, you can use tabs to share content between https://jqueryui.com/tabs/

0
source share
 <a href="./profile.html>profile</a> 

use ./ {filename} to access the file in the same directory

0
source share

All Articles