Friday, November 19, 2010

How to load a different HTML document in another directory?

Let's say I have a normal folder with the 'index' file. Then in that folder I got a folder named example 'Band'. And in Band I got a html document. How do I make a link back to the index in the previous folder?How to load a different HTML document in another directory?
Use ';../'; (without quotes) to send browsers up one directory. Use as many times with folder names to get the right relative path. Basically...



%26lt;p%26gt;%26lt;a href=';../index.html'; title=';Home Page';%26gt;Home%26lt;/a%26gt;%26lt;/p%26gt;



RonHow to load a different HTML document in another directory?
Use .. (two periods)



for example inside Band/myband.html, there's a link to the index.html page as:



%26lt;a href=';../index.html';%26gt;



or you can use absolute path by put / in front of the URL:



%26lt;a href=';/index.html';%26gt;
There are two ways you can do this.

1. Using absolute path, the whole address, not advised because it will be harder to modified the code if you were to move it to a different server.

2. Using relative path, relative to the files and folders in the root directory.



Use the second option, relative path by using ';../';, goes up one level.

Example: %26lt;a href=';../index.htm'; alt=';';%26gt;Home Page%26lt;/a%26gt;

No comments:

Post a Comment