PDA

View Full Version : Script Working Directory



pilau
08-08-2006, 07:35 PM
Let's say I have an HTML page in the root directory "/".
Now, in the folder (root)/scripts, I have a .js file which is included in the HTML file.
In the JavaScript code I am settin a new source URL for an image in the HTML page. The image is located inside the folder (root)/images.

So, for calling the image from the HTML file I would do this: src="./images/image.ext". But from what is the directory path I should use from the JS file? imageObject.src = 'what path?'

vwphillips
08-08-2006, 09:15 PM
the javascript should be considered as part of the page and therefore at the same directory path and level

Mr J
08-08-2006, 09:20 PM
Try

../images/pic01.jpg

pilau
08-08-2006, 11:54 PM
the javascript should be considered as part of the page and therefore at the same directory path and level

You were right. Thanks you very much.