Forum Moderators: open
root/two/index.htm
root/two/files/images/pict888.jpg
root/shared/files/js/test1.js
root/shared/files/xml/datafile.xml
The index.htm files in folder one and two has reference to .js file -----
<script src="../shared/files/js/test1.js" type="text/javascript"></script>
in head section. That is simple.
Now the .js file has code to open xml file as follows:
QUESTION 2 what this imagepath could be?
.
.
.
QUESTION 3 For the above file/folder structure do path and imagepath change depending its on location - local machine or web server?
Thanks
Q2. Again, the path should be relative to the HTML file. Since folders one and two have the same structure, then the paths are the same to get to their corresponding image folder. eg. "files/images/picture.jpg" and "files/images/pict888.jpg" respectively. Again, you could use root-relative paths ie. "/one/files/images/picture.jpg" and "/two/files/images/pict888.jpg" which would enable you to easily access an image in the two folder from the HTML file in the one folder.
Q3. If you are using relative paths then the path and imagepath will/could vary according to where the HTML file is located. (Using root-relative paths would avoid this and perhaps having your HTML files all at the same level would also help - which you have anyway). Different web servers or browsers/machines will not effect what path is required.
Generally, all client side paths are relative to the HTML document. Except in CSS files when image paths are relative to the CSS file. (But if you used root-relative paths, it wouldn't matter)
Also, you might want to consider the BASE element. This enables you to specify a (different) path that all relative links on the page are... relative too. So, relative links on the page will no longer be relative to the HTML document itself.