Petrus K. Petrus K. - 2 years ago 60
Javascript Question

Accessing JavaScript file in HTML through parent level directories on an HTTP server

I'm trying to access hellotest.js, which is located in the parent directory of my index2.html file.

I'm having no luck doing this, the fix should be simple and I have tried looking for an answer.

The absolute path to the files are (Ubuntu/Linux):

/home/petrus/dev/testbeds/http-server/index2.html
/home/petrus/dev/testbeds/hellotest.js

EDIT: I'm running this on an http-server: http-server, SimpleHTTPServer

<!DOCTYPE HTML>
<html>
<head>
<script src="../hellotest.js" type="text/javascript"></script>
<title>test website</title>
</head>
<body>
<p>hello world 2</p>
</body>
</html>

Answer Source

I resolved this problem eventually by creating symlinks.
In Linux/Ubuntu you can do this with: ln -s <symlink_origin> <symlink_destination

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download