# Pathstring = "..\images\picture.jpg" or Pathstring = "images\picture.jpg" ?

## Recommended Posts

I have been following various discussions on image preloading and my web site has these 2 items, "images" (folder) & "scripts.js" in the same directory.Which of these 2 lines of javascript is correct when called from 'scripts.js':pathstring = "..\images\picture.jpg" or pathstring = "images\picture.jpg", as I have seen both used?

##### Share on other sites

they're both wrong for the same reason, somewhat related to the issue at hand. in both cases it should be a forward slash. on the actual case of the trailing ../ and whatnot, it depends on the situation. Those two lines mean two different things. The ../ will move you up one directory from your CWD (current working directory). So ../ will move you up one from whatever directory script.js is in.Since both the folder and the file referencing the folder are in the directory, the second line, with forward slashes, would be what you need.

images/picture.jpg

##### Share on other sites

Thanks for that. I will use "images/picture.jpg" then, although "images\\picture.jpg" works too. Typo on my part, sorry.

## Create an account

Register a new account