Archdeacon Posted March 10, 2011 Share Posted March 10, 2011 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 More sharing options...
thescientist Posted March 10, 2011 Share Posted March 10, 2011 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 More sharing options...
Archdeacon Posted March 11, 2011 Author Share Posted March 11, 2011 Thanks for that. I will use "images/picture.jpg" then, although "images\\picture.jpg" works too. Typo on my part, sorry. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.