0

Knowing that we have the file URI protocol to reference local files in a browser bookmark as this question ( Meaning of '///' after 'file:' protocol (URL) ) already explains...

What if I wnat to use an environment variable into this path? Is it possible?

For example, I would like to use windows 'USERPROFILE' like that:

file:///%USERPROFILE%/someFolder/someFile.html

Instead of having the fixed:

file:///C:/Users/miwindowsusername/someFolder/someFile.html

3
  • Basically you could use a variable from an .env file to build a path. But you need to process that on the server-side before the browser can render the path in your html code (for example in PHP). Can't think of a way to do this in plain html (via javascript calling a PHP file maybe but then you could do it on the server-side directly). Naming PHP as an example only, there are more Commented Feb 8, 2024 at 13:07
  • @Luckyfella, so even on a Linux-based OS (where environment variables are called with $) file:///$HOME/.mozilla/firefox/fimaebr1.default-release-1720105233406/prefs.js entered into a browser omnibox (as an example) shouldn't work? Commented Sep 17, 2024 at 14:15
  • This question is similar to: Using Windows environmental variables in file URI scheme. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Sep 17, 2024 at 14:16

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.