Relative paths.

 

Instead of using links like http://www.site1.com/Guide/HTML_Pages/Ch2.html or file://localhost/C:/WINDOWS/Desktop/Guide/HTML_Pages/Ch2.html or C:\WINDOWS\Desktop\Guide\HTML_Pages\Ch2.html you can use Ch2.html

What you need to type depends on where this page is and where the other is. You'll have to check that (do it twice and you will do it much faster than typing the full URL). The other advantage is that the pages will work where ever they are: on a floppy, your harddisk, site1 or site2. But they need to be in the same relative space of course.

This picture may help understand:

This is a screenshot of the directory that's somewhere on your system when you look at this page.

The directory is called Guide. It does no longer matter where the directory Guide is, all that's required for the pages to keep working, is that the content of this directory doesn't change. It's possible to add files of course, but don't rename Images to pictures or move the content to HTML_Pages. You could say that Guide takes care of all the possible http://www.blabla and file://localhost.mutter bits.

Here's the content of the directory HTML_Pages:

-Ch1.html is the page you're looking at now. There was a relative link on index.html to bring you here: HTML_Pages/Ch1.html

When standing in the directory Guide (which is where index.html is) you need to go into the directory HTML_Pages and then open the file Ch1.html. This path is sometimes also written as ./HTML_Pages/Ch1.html . The dot just means in this directory.

-Ch1.html will link to Ch2.html (next page): you can just type: Ch2.html (./Ch2.html). Try

-This page will also get a link back to the index. You need to go out of the subdirectory and load the file index.html. Type double dot  .. to go from a subdirectory to a directory 1 level above (parent directory). So ../index.html is the URL required to go from here to the index. Try

 

-The pictures on this page are stored in the other subdirectory Images. You combinate the first and the 3th 'technique' to make relative paths for that. This page is in the subdirectory HTML_Pages, so you need to go to the level above it first: a double dot. Then you are in Guide and need to go into Images: Images/. Then load a picture, mail.gif for example. The URL becomes ../Images/mail.gif

It is possible that the directory HTML_Pages contains another subdirectory with a html page. The double dot only goes up 1 level and you need to go up 2 levels to get the same result for that faraway page as this one: ../../Images/mail.gif .

Finally a silly, yet working example. You're here and want to go to Ch2.html. You already know that just Ch2.html will do the trick. But you can also go out of the subdir and back into it again: ../HTML_Pages/Ch2.html .

-Look where you are.

-Determine where you want to go to.

- Double Dot  to go 1 level up.

-Type the name of a directory to go into that directory.

 

The same files you have on your harddisk are also at http://www.totalwar.org/strategy/frog/Guide  Not one URL is changed.

 

Just use full URLS to go to other websites.

The browser does not only handle html pages this way: any file can be relative linked. It depends on the host settings what happens: .zip and .exe will result in downloading of the file. .gif will result in a new browserpage displaying just that picture, so you use the img border="0" src="../ bit to display them on this page.

 

Previous                                               Index                                                                           Next

True, pretty useless here :)