Monday, 9 February 2015

LINKING LOCAL PAGES USING RELATIVE AND ABSOLUTE PATHNAMES

LINKING LOCAL PAGES USING RELATIVE AND ABSOLUTE PATH NAMES
 The example in the preceding section shows how to link together pages that are contained in the same folder or directory on your local disk (local pages). This section continues that thread, linking pages that are still on the local disk but might be contained in different directories or folders on that disk. 

NOTE
Folders and directories are the same thing, but they’re called different namesdepending on whether you’re on Macintosh, windows, or UNIX. I’ll simply call them directories from now on to make your life easier.
When you specify just the filename of a linked file within quotation marks, as you did earlier, the browser looks for that file in the same directory as the current file. This is true even if both the current file and the file being linked to are on a server somewhere else on the internet; both files are contained in the same directory on that server. It is the simplest form of a relative path name.
Relative path names point to files based on their locations relative to the current file. They can include directory names, or they can point to the path you would take to navigate to that file if you started at the current directory or folder. A path name might, for example, include directions to go up two directory levels and then go down two other directories to get to the file.
To specify relative path names in links, you must use-style paths regardless of the system you actually have, you therefore separate directory or folder names with forward slashes (/)., and use two dots to refer generically to the directory above the current one(…).
Table 5.1 shows some examples of relative pathnames and where they lead.
TABLE 5.1 relative path names
                                 Path name                         means

path name
means
Href=”file.html”
File. Html is located in the current directory.
Href-“files/file.html”
File.html is located in the directory called files (and the files directory is located in the current directory).

Href=”files/more files/file.html”
File.html is located in the more files directory, which is located in the files directory, which is located in the current directory.
Href=”…/file.html”
File.html is located in the directory one level up from the current directory (the parent directory).
Href=”../../files/file.html”
File. Html is located two directory levels up, in the directory files.


If you’re linking files on a personal computer (Macintosh or PC), and you want to link to a file on a different disk, use the name or later of the disk as just another directory name in the relative path.
When you want to link to a file on a local drive on the Macintosh, the name of the disk is used just as it appears on the disk itself. Assume that you have a disk called hard disk 2, and your HTML files are contained in a folder called HTML files. If you want to link to a file called jane. Html in a folder called public on a shared disk called jane’s  mac, you can use the following relative pathname:
Href=”../../ jane’s mac/public/jane.html”
When linking to a file on a local drive on windows systems, you refer to the drives by letter, just as you would expect. However, rather than using c:, d:, and so on, substitute a pipe (|) for the colon (the colon is already used to separate the scheme from the host name in URLs). The pipe looks like two vertical dashes stacked on top of each other, and is usually found on the backslash Key. Don’t forget to use forward slashes as you would with UNIX. So, if the current file is located in c:/FILES/HTML/. And you want to link to D:/FILES. NEW/HTMLMOREINDEX.HTM, the relative pathname to that file is as follows:
HREF=”../../D||/FILES. NEW/HTML/MORE/INDEX.HTM”
In most instances, you’ll never use the make of a disk in relative pathnames, but I’ve included it here for completeness. After you deploy your pages to the web, links that include drive makes won’t work, so it makes more sense to use relative links, which are more potable.

No comments:

Post a Comment