Read HTML The Definitive Guide Online
Authors: Chuck Musciano Bill Kennedy
oreilly.com& [email protected] sets the subject and carbon-copy address. (This line would normally appear as a single line but is broken here due to the width of the page.) Internet Explorer Version 3 does not recognize the bcc and cc fields in the mailto URL and will either complain about them if they appear alone or append them to a preceding subject.
7.2.9 The telnet URL
The telnet URL opens an interactive session with a desired server, allowing the user to log in and use the machine. Often, the connection to the machine automatically starts a specific service for the user; in other cases, the user must know the commands to type to use the system. The telnet URL has the form:
telnet://
user
:
password
@
server
:
port
/
7.2.9.1 The telnet user and password
The telnet
user
and
password
are used exactly like the user and password components of the ftp URL, described previously. In particular, the same caveats apply regarding protecting your password and never placing it within a URL.
Just like the ftp URL, if you omit the password from the URL, the browser should prompt you for a password just before contacting the telnet server.
If you omit both the user and password, the telnet occurs without supplying a user name. For some servers, telnet automatically connects to a default service when no username is supplied. For others, the browser may prompt for a username and password when making the connection to the telnet server.
7.2.9.2 The telnet server and port
The telnet server and port are defined similarly to the http server and port, described above. The server must be the Internet domain name or IP address of a telnet server; the port is the port on which that server is listening for requests. If the port and its preceding colon are omitted, the default port of 23 is used.
7.2.10 The gopher URL
Gopher is a web-like document retrieval system that achieved some popularity on the Internet just before the World Wide Web took off, completely replacing Gopher. Some Gopher servers still exist, though, and the gopher URL lets you access Gopher documents. The gopher URL has the form: gopher://
server
:
port
/
path
7.2.10.1 The gopher server and port
The gopher server and port are defined similarly to the http server and port, described previously. The server must be the Internet domain name or IP address of a gopher server; the port is the port on which that server is listening for requests.
If the port and its preceding colon are omitted, the default port of 70 is used.
7.2.10.2 The gopher path
The path can take one of three forms:
type
/
selector
type
/
selector
%09
search
type
/
selector
%09
search
%09
gopherplus
The
type
is a single character value denoting the type of the gopher resource. If the entire path is omitted from the gopher URL, the type defaults to 1.
The
selector
corresponds to the path of a resource on the Gopher server. It may be omitted, in which case the top-level index of the Gopher server is retrieved.
If the Gopher resource is actually a Gopher search engine, the
search
component provides the string for which to search. The search string must be preceded by an encoded horizontal tab (%09).
If the Gopher server supports Gopher+ resources, the
gopherplus
component supplies the necessary information to locate that resource. The exact content of this component varies based upon the resources on the gopher server. This component is preceded by an encoded horizontal tab (%09). If you want to include the
gopherplus
component but omit the search component, you must still supply both encoded tabs within the URL.
7.2.11 Absolute and Relative URLs
You may write a URL in one of two ways: absolute or relative. An absolute URL is the complete address of a resource and has everything your system needs to find a document and its server on the Web. At the very least, an absolute URL contains the scheme and all required elements of the
scheme_specific_part
of the URL. It may also contain any of the optional portions of the
scheme_specific_part
.
With a relative URL, you provide an abbreviated document address that, when automatically combined with a "base address" by the system, becomes a complete address for the document. Within the relative URL, any component of the URL may be omitted. The browser automatically fills in the missing pieces of the relative URL using corresponding elements of a base URL. This base URL is usually the URL of the document containing the relative URL, but may be another document specified with the
[
7.2.11.1 Relative schemes and servers
A common form of a relative URL is missing the scheme and server name. Since many related documents are on the same server, it makes sense to omit the scheme and server name from the relative URL. For instance, assume the base document was last retrieved from the server
www.kumquat.com
. The relative URL, then: another-doc.html
is equivalent to the absolute URL:
http://www.kumquat.com/another-doc.html
Table 7.2
shows how the base and relative URLs in the example are combined to form an absolute URL.
Table 7.2: Forming an Absolute URL
Protocol Server
Directory File
Base URL
http
www.kumquat.com /
Relative URL
-v
-v
-v
another-doc.html
-v
-v
-v
-v
-v
Absolute URL http
www.kumquat.com /
another-doc.html
7.2.11.2 Relative document directories
Another common form of a relative URL omits the leading slash and one or more directory names from the beginning of the document pathname. The directory of the base URL is automatically assumed to replace these missing components. It's the most common abbreviation, because most HTML authors place their collection of documents and subdirectories of support resources in the same directory path as the home page. For example, you might have a
special/
subdirectory containing FTP
files referenced in your HTML document. Let's say that the absolute URL for that HTML document is:
http://www.kumquat.com/planting/guide.html A relative URL for the file
README.txt
in the
special/
subdirectory, then, looks like this: ftp:special/README.txt You'll actually be retrieving:
ftp://www.kumquat.com/planting/special/README.txt
Visually, the operation looks like that in
Table 7.3
.
Table 7.3: Forming an Absolute FTP URL
Protocol Server
Directory
File
Base URL
http
www.kumquat.com /planting
guide.html
Relative URL
ftp
-v
special
README.txt
-v
-v
-v
-v
-v
Absolute URL ftp
www.kumquat.com /planting/special README.txt
7.2.11.3 Using relative URLs
Relative URLs are more than just a typing convenience. Because they are relative to the current server and directory, you can move the entire set of documents to another directory or even another server and never have to change a single relative link. Imagine the difficulties if you had to go into every source HTML document and change the URL for every link every time you move it. We'd loathe using hyperlinks! Use relative URLs wherever possible.
7.1 Hypertext Basics
7.3 Creating Hyperlinks