Absolute file path for java script

Alex picture Alex · Jun 18, 2011 · Viewed 11.7k times · Source

I have a small javascript library written by myself. I want to reference it in my web application, but it doesn't work

<script src='file:\\C:\Path\To\Script\Script.js'></script>

Is it possible to reference javascript when all you know is the absolute path?

Answer

KooiInc picture KooiInc · Jun 18, 2011

The file: url needs 3 forward slashes, and the path also needs forward slashes:

<script src='file:///C:/Path/To/Script/Script.js'></script>

This will ofcourse only work if you load the script within a html-file on your disk that's loaded in your browser.