Linking to Other Files and Email


You can link to more than just other people's Web sites. You can use the same HRef attribute to link to email addresses for other pages of your own Web site, or even to other files on your own computer. The hyperlink to point to another file (second.htm) on my own computer, for example, is shown in the following code. In this example, the second.htm file is stored in the same directory as the page linking to it.

Please <a href="second.htm">click here</a> to open    my second Web page.


If, however, my second.htm file was stored in another directory (for example, the Links directory), the hyperlink would need to include the directory name too, as in the following:

Please <a href="links/second.htm">click here</a> to open    my other page.


Tip

Did you know that you can force your hyperlink to open a new browser window? This is especially handy if you want to link to someone else's Web site without directing traffic away from your own site. Use the target="_blank" attribute, as in the following example. Try it!

<a href="http://www.somewhere.com/page.htm" target="_blank">    Click here</a> to open a related Web site.



The HRef attribute changes slightly if you want to link to a file that is not part of your Web site. You need to tell the Web browser that the file is not located on the Web server. You can see how that is accomplished in the following example:

<a href="file:\\servername\foldername\filename.extension">    Click here</a> to open my favorite file.


If I want to link to my dogs.doc file in the 4legs folder of my animals server, for example, my hyperlink looks like the following:

<a href="file:\\animals\4legs\dogs.doc">click here</a>    to open my favorite file.


Caution

Did you notice that the direction of my slashes changes when I change my link type from http:// to file:\\? The forward slash (/) is always used to separate directory folders on a Web file server. The backslash (\) is used to separate directory folders in Windows and DOS.


You also can link to an email address by using the mailto prefix, as shown in the following code line. When you click on the words click here, an email window that enables you to type your message to Mickey Mouse appears.

<a href="mailto:mickey.mouse@disney.com">Click here</a>    to send mail to Mickey.




Sams Teach Yourself HTML in 10 Minutes
Sams Teach Yourself HTML in 10 Minutes (4th Edition)
ISBN: 067232878X
EAN: 2147483647
Year: 2004
Pages: 151
Authors: Deidre Hayes

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net