Andrey Bushman
Andrey Bushman

Reputation: 12506

Why browser can't find the js-files from the `../lib/` (relative) location?

I learn WebGL. I read this book and try to run its samples. I set the current directory for the D:\WebGL\ch02 and run the local web-server:

python -m http.server 8001

and open the http://localhost:8001/ColoredPoints.html file. But I get an error message:

Uncaught ReferenceError: getWebGLContext is not defined

From the D:/WebGL/ch02/ColoredPoints.html file:

<script src="../lib/webgl-utils.js"></script>
<script src="../lib/webgl-debug.js"></script>
<script src="../lib/cuon-utils.js"></script>
<script src="ColoredPoints.js"></script>

If I copy the ../lib/ directory (with its js-files) into current subdirectory - all works fine. The ../lib/ is the common directory (with the common js-files) for the all samples of the book.

Why it doesn't work for the ../lib/ location?

Upvotes: 1

Views: 1470

Answers (2)

deyhle
deyhle

Reputation: 473

.. goes up one level, but you are already at the root of your hostname. So you will have to put them into a sub-directory and use . instead of ..

Upvotes: 2

Quentin
Quentin

Reputation: 943586

The root of the website is D:\WebGL\ch02

You cannot go above it.

If you want to serve files from D:\WebGL\lib then you need to either set the root of the site to D:\WebGL\ or move the lib directory inside ch02 (and remove the ..).

Upvotes: 2

Related Questions