Jump to content

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


Archdeacon
 Share

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?

Link to comment
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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...