Hi, I’m trying to make a website work offline for a customer as an app, but I’m having some issues. Root relative href’s and src’s aren’t working. Is there a way to set a “base” path for all href’s and src’s in html and css files, like making the base path the location of the main.js? Thanks!
This question isn’t specific to Atom. You will probably have better luck finding an answer for this question on Stack Overflow.
Oh, I didn’t notice this discussion board was for Atom. The question is intended for Electron.
The board is for both, but the way your post is written doesn’t necessarily scream Electron.
I don’t know if it’s possible to have Electron act like it has a domain name with what’s built into it, but you might be able to set up a server inside your app and have
BrowserWindows pointing at whatever
localhost port you end up using.
@DamnedScholar, thanks for suggestion. I’m not looking for way to make Electron act like it has a domain though. Hopefully this will help calrify: I’m trying to find a way so that when I have a root relative url in my html such as , Electron will look for it in C:\Path\to\App\path\to\img.jpg rather than C:\path\to\img.jpg. I would like the root relative to relative to be relative to apps directory rather than the drive like in NW-JS.
A root-relative path (
src="/path/to/img.png") is entirely reliant on having a domain or IP that it can refer back to.