Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Absolute file path for java script

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?

like image 766
Alex Avatar asked Jun 18 '11 10:06

Alex


People also ask

What is the absolute path of a file?

A path is either relative or absolute. An absolute path always contains the root element and the complete directory list required to locate the file. For example, /home/sally/statusReport is an absolute path. All of the information needed to locate the file is contained in the path string.

How do you specify an absolute path?

An absolute path is defined as specifying the location of a file or directory from the root directory(/). In other words,we can say that an absolute path is a complete path from start of actual file system from / directory. Relative path is defined as the path related to the present working directly(pwd).


1 Answers

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.

like image 93
KooiInc Avatar answered Oct 02 '22 23:10

KooiInc