Chapter 7

Linking HTML Documents

by John Jung


CONTENTS

As you learned in chapter 4, "Building Blocks of HTML," putting a link in your home page to someone else's page is pretty easy. But now you're ready for something more advanced: linking your page to other resources on the Internet. The World Wide Web is just one of many resources on the Net; creating links to others is important. You don't always need to link your home page, but knowing how is good if you ever want to do it. Fortunately, creating links to other resources on the Net through your home page is very easy.

In this chapter, you learn about the following:

Linking to Other Net Resources

The World Wide Web is a popular part of the entire Internet, but many other resources are available. Most of them were around long before the Web was even born, and as a result, they have a lot of stuff on them. Also as a result of the Web's newness, the other resources sometimes have a much wider audience base. Whether you're designing a home page for yourself or for your company, you may want to know how to link to those resources.

These resources can take various shapes, from the peanut gallery that is Usenet news to personal e-mail to the capability to access other computers through Telnet. Although you can create your own versions of these resources using forms (see Part IV, "Forms and CGI"), most of the time you wouldn't want to do so. For example, you could easily create a page with many HTML form tags, text elements, and a submit button for e-mail, but simply creating a link to e-mail with a particular address would be easier. This way, you can more easily update the page because you don't have to worry about which forms to read. Also, sometimes browsers have built-in support for some of the other resources, giving the user faster response time.

You especially want to create links to other resources on the Net if you're already using a resource. If you already have a Gopher site with information that's updated automatically, why rebuild it to fit the Web? Just adding a hyperlink to your Gopher site makes more sense. Similarly, if you're running a BBS that's on the Internet, putting in a Telnet link to it makes more sense. There's no reason for re-creating, or even mirroring, your BBS through forms for the Web.

Creating a Link to E-Mail

The single most popular activity on the Internet is sending e-mail. More people use e-mail than any other resource on the Net. The reason is quite simple: If you're on the Internet, you have an e-mail address. The provider that gives you access to the Net often has at least one e-mail program available for your use. Most modern e-mail programs offer a friendly interface, with no complex commands to learn.

You'll most likely want to put in an e-mail link when you want people to give you feedback on a particular topic. Whatever it is you want comments on-be it your home page or your company's product-if you want to know what people think, use an e-mail link. E-mail links are also useful for reporting problems, such as a problematic or missing link. Typically, the Web master of a particular site should put these types of links to himself or herself. You really have no reason not to put in a link to your e-mail address.

Creating a link to an e-mail address is similar to creating a link to another home page. The only difference is the reference point for your anchor element. Normally, you put a link to a home page around some text as in the following:

<A HREF="http://www.mycom.com/myhome.html">Go to my home page</A>.

Linking to e-mail is just as simple. Instead of entering http, which specifies a home page, type mailto: to specify an e-mail address. And instead of specifying an URL, put in your full e-mail address. So the preceding example now looks like this:

<A HREF="mailto:me@mycom.com">Send me E-mail</A>.

The link created with the preceding HTML code will look like any other hypertext link. You can easily mix and match hyperlinks to different resources, and they'll all look the same (see fig. 7.1). When this link is selected, the browser opens its own e-mail interface for the user. Each interface is different, but most of them automatically get your e-mail address and real name, and prompt you for a subject.

Figure 7.1 : E-mail links look just like regular hypertext links.

Tip
If you're creating a Web page of limited distribution, you don't need to put in your entire e-mail address. This often occurs in very large companies or universities, where there are internally available Web pages. Instead of putting in your complete e-mail address, just use your username. So instead of putting in:
<A HREF="mailto:me@mysite.com">
you'd use:
<A HREF="mailto:me">

Because the e-mail link is a standard URL and easily implemented, many browsers have built-in support for it. As a result, when people click an e-mail link, the Web browser will put up a primitive mail program. A few companies offer a full set of Internet applications, from an e-mail program, to a newsreader, to a Web browser. Oftentimes, these work in conjunction with each other. Consequently, when you click an e-mail link, these Internet packages will start up their own e-mail program (see fig. 7.2).

Figure 7.2 : Netscape will launch its own internal and full featured e-mail program when you click an e-mail link.

Creating a Link to Usenet News

Usenet is one of the best, or worst, resources on the Net, depending on whom you ask. Anybody with an opinion can tell you what he thinks. That person may not know what he is talking about, but he can let you know what he thinks. Usenet is the ultimate embodiment of the freedom of speech, letting everybody say anything they want.

This ability of anybody anywhere on the Net having a voice could be an asset to your home page. Often, you may want to put in a link to Usenet when you want people to read for more information. If your home page has some information about HTML authoring, for example, you might want readers to go to a particular newsgroup for more help. You can also include such a link so that people can see what differing opinions are. If you have a certain political view and want others to see what the opposition is, a Usenet news link would be helpful.

Creating a link to a Usenet newsgroup is pretty simple; this kind of link is also just a derivative of the basic hypertext link. As you did with the e-mail link, you need to modify two parts in the anchor reference. When you're creating a Usenet link, enter news: instead of http:. Likewise, instead of specifying a particular URL, you put in a specific newsgroup, as follows:

  For more information, see <A HREF="news:news.newusers.questions">news.newusers.questions</A>.

As you can see in figure 7.3, the Usenet news hyperlink looks identical to other links. When a user selects such a link, the browser tries to access the user's Usenet news server. If the news server is available to that person, the browser then goes to the specified newsgroup. The user can then read as much as he or she likes in that particular group.

Figure 7.3 : Usenet news links allow you to make a point to people interested in your topic.

Caution
When a user clicks a Usenet news link, his or her browser tries to access the news-group in question. Because it's this user's browser and environment, he or she might not have access to the group you specified. Not all Internet providers have access to the same newsgroups. When you're creating such links, be mindful that not everybody will necessarily be able to access them.

How a Usenet hyperlink is handled is left entirely up to the Web browser the person is using. Many of them treat each article in a newsgroup as an individual hyperlink. Often, there's little in the way of sophisticated newsreading features. Some companies, such as Netscape, offer an entire suite of programs, including a Usenet newsreader (see fig. 7.4). In these cases, the newsreading portion of that suite is started up.

Figure7.4: When a Usenet link is accessed, some sophisticated Web browsers will start up their own internal newsreader.

Making FTP Available on Your Site

Another popular activity is accessing an FTP site. FTP, or File Transfer Protocol, allows users to copy files from other computers (the FTP site) onto their own computers. This popular method allows companies to distribute their demo software or patches to their products.

Putting in a link to an FTP site allows users to get a specific file from a particular location. This capability is useful for companies and shareware authors in making their products available. This type of link is also great for people who review software, allowing them to let users get the files being reviewed. Also, people who have files, such as FAQs and interesting pictures that they want others to get to easily, might want to put in a link to an FTP site.

You create a link to an FTP site the same way you create other links, and they look the same, too (see fig. 7.5). You enter ftp: instead of the usual http:, and you change the URL address to //sitename. Simply put, the site name looks the same as the URL address. You need to make sure that the site name you specify points to a machine that accepts FTP connections. FTP links are almost always supported by the browser natively. You can create a typical FTP link as follows:

Figure 7.5 : An FTP link allows many people to access a particular file.

You can get the FAQ <A HREF="ftp://ftp.mysite.com/pub/FAQ">here</A>.

Note
If you don't specify a particular file name, the browser will list the files in the directory you specified. This is particularly useful if you want the user to have access to multiple files. Programs available on multiple machines, or large files broken up into several chunks, typically fall into this category.

Technically speaking, there isn't too much of a difference between FTP and the Web. As a result, Web browsers support FTP links without needing another program. The browsers will give you a list of the files in the current directory, and indicate which ones are directories and which ones are files (see fig. 7.6). If you click a directory, it'll change into that directory. If you click a file, the browser will directly download the file.

Figure 7.6 : Web browsers will have no problems handling FTP links by themselves.

Troubleshooting
Some people can't access some of my FTP links.
If a lot of people are reporting that they can't access some of your FTP links, try finding others. This error usually comes up when you have an FTP link to a particularly busy FTP site. You should try to locate other (less busy) FTP sites that have the same file you're pointing to.

Anonymous versus Non-Anonymous FTP Links
By default, when FTP links are activated, the FTP connection that's made is known as anonymous FTP. This means that the FTP site the user is trying to access doesn't care who the user is. All the anonymous FTP site cares about is sending and receiving files to anybody who logs in with the username "anonymous." The password is often the e-mail address of the user, but this isn't necessary. Anonymous FTP allows software companies and the like to distribute their products to a very wide audience.
A non-anonymous FTP is where the FTP site is very particular about who can access it. To get access to a non-anonymous FTP site, you must have an account on the FTP site itself. Basically, you can't get into a non-anonymous FTP site unless you're already in. This is probably the most widely used FTP site around, as many companies allow employees to FTP into their own accounts.

Note
You can easily change an anonymous FTP link into a non-anonymous one. Simply put a username and the "@" sign before the sitename. This will cause most Web browsers to automatically attempt to log in as username. The browser will then prompt the user for the password for the login id.

Linking Your Home Page to a Gopher Site

Before there was the World Wide Web, there was something known as Gopher. It was originally designed by the University of Minnesota (the Golden Gophers) as a way of making information that's spread out easily available. Gopher has probably been the Internet resource most affected by the Web, often being superseded by it. The biggest difference between Gopher and the Web is that it is very difficult for individual people to create their own Gopher sites or holes.

Though Gopher sites are not as prevalent as they once were, they still have a strong following. You can typically find Gopher sites at places that dispense a lot of automated information. Although the site could often easily be converted to HTML, it simply hasn't bothered to. This conversion of Gopher data into usable HTML code is typically the work of a programmer, and often not worth the effort. Putting in an HTML link to a Gopher site allows people browsing your page easy access to a great deal of information.

You can create a link to a Gopher hole by modifying the same two elements of the anchor reference. Change the http: to gopher:, and change the URL to //sitename. The site name must be a valid Internet host name address. The link created looks like every other type of hypertext link (see fig. 7.7), and built-in support is provided by most Web browsers. A Gopher hole link usually looks something like the following:

Figure 7.7 : Links to Gopher holes are great for accessing large amounts of automated information.

For more information, go <A HREF="gopher://gopher.mysite.com">here</A>.

Just like FTP, Gopher is a Net resource that is built into HTML. Consequently, most Web browsers will support any links to a Gopher site internally. That is, you don't need a Gopher-specific application to go to a Gopher site; the browser will take care of it for you. But just like FTP, the built-in support for Gopher is often very bland (see fig. 7.8).

Figure 7.8 : There's only so much a Web browser can do to liven up the textbased Gopher resource.

Providing Access to a Large Database with a WAIS Link

WAIS stands for Wide Area Information System, which basically means "lots of large databases that you can search through." WAIS was specially designed by WAIS Corp. as a way of accessing large amounts of information. This capability is very different from what Gopher and the Web do in that WAIS was intended to cover very large chunks of information. Typically, databases that contained several million entries were considered appropriate for WAIS.

WAIS is generally accessed through a search engine because most people don't want to plod through such large stores of information. When WAIS was first introduced, custom front ends allowed easy access to a WAIS database. With the advent of the Web, however, most WAIS databases now have HTML front ends to their databases (see fig. 7.9). Now you can simply fill out a Web form and click a button, and the WAIS search is underway.

Figure 7.9 : Most WAIS databases are now searchable through HTML forms.

You can create a link in your home page to a WAIS database as easily as you do with all the other links. You have to modify the same two anchor reference elements to hold the correct information. Instead of using http:, enter the prefix wais:, and change the URL location to be the address of a WAIS database:

To search for a number in your area, click <A HREF="wais://wais.mysite.com">here</A>.

Note
Most browsers don't have built-in support of WAIS database searches. If you put in a link to one of these databases, be sure to include some sort of reference to where users can get a WAIS client. Of course, if the WAIS database you're pointing to has HTML forms support, you don't need to worry about including such information.

Accessing Remote Computers with Telnet Links

The capability to access other computers is not something new to the Web; it's been around for a long time. This access has always been achieved with a UNIX program called Telnet, which doesn't stand for anything in particular. Telnet allowed people to try to log in to a remote machine, much the same way some people access their Internet providers. The Web allows for support of accessing remote machines through a Telnet link to a remote computer.

Usually, people trying to get on a secure system are the people for whom you want to provide a Telnet link. People who provide access to a private, Internet-accessible BBS will most likely want to put in a Telnet link. Also, companies that offer a BBS for customer support may want to make use of a link to a Telnet site. Generally speaking, for most home pages, you have little or no reason to include a link to a remote site.

As you might have guessed, creating a Telnet link to a remote site requires modifying the anchor reference element. You change the http: to telnet:. You also need to change the URL part of the anchor reference to hostname. Hypertext links that refer to Telnet sites look the same as other links (see fig. 7.10). A typical Telnet link takes the following form:

Figure 7.10: Usually, only BBSs have a need for Telnet links.

Click <A HREF="wais://wais.mysite.com">here</A> to access our BBS.

Note
Most Web browsers do not support Telnet activity natively. They typically depend on an external application to talk correctly to the remote machine. If you put in a link to Telnet to another site, be sure to also include some reference to a Telnet client.

Note
There are a few operating systems that have built-in Telnet capability. Among the Oss that have this are Windows NT and UNIX.

Even though Telnet is a rather simple Net resource, it's also a very difficult one. Among the many problem are issues of how to display the remote session and how to interpret keypresses. As simple as these problems may appear, they're hard to implement in a Web browser. For these reasons, most Web browsers don't have support for Telnet. Rather, they leave it up to the individual person to find a Telnet program and set it up (see fig. 7.11).

Figure 7.11: Most Web browsers don't support the Telnet links internally, so you need another program to access these links.

Tip
Some Web browsers allow something extra in the anchor reference. Simply add the username you want the person to log in as, followed by the "@" sign, before the sitename. So that instead of:
Access my <A HREF="telnet://mysite.com/">system!</A>
You can have:
Access my <A HREF="telnet://john@mysite.com/>system</A>
On those browsers that support this, the Web browser will pop up a little notice. This notice tells the user what login name should be used to access the system.

How Links Work Together

You may be wondering how well these hypertext links work with each other. The answer is: very well. Even though the links are different, they all look and behave the same. This common behavior exists because of the anchor reference that all hyperlinks use. Some may need client programs not built in to a Web browser, but that's not a big deal. This identical look and feel of various hypertext links allows home pages to have a consistent feel. Consistency in a home page is important because it allows people to simply "know" they're in your home page without looking at the current URL.

The best thing you can do is to treat all hypertext links in the same manner, with slightly different formats. Just take the same basic anchors, add a reference, and put in the correct pointer to that reference (see table 7.1). As a Web author, you must always remember that each person looking at your home page could be using any browser available. No hard and fast rules about what resources all browsers will support even exist. Whatever resource you want to link to, though, try to include a link to a location where the user can get a client.

Table 7.1  Sample Formats for Creating Links

Link To…What to Use Sample Link
Another home pagehttp://sitename/ http://www.mysite.com/
An e-mail addressmailto:address mailto:me@mysite.com
A Usenet newsgroupnews:newsgroupname news:news.newusers.questions
An FTP siteftp://sitename/ ftp://ftp.mysite.com/
A Gopher sitegopher://sitename/ gopher://gopher.mysite.com/
A WAIS databasewais://sitename/ wais://wais.mysite.com/
Another computertelnet://sitename/ telnet://bbs.mysite.com/