Section 11.4. Alternative Protocols


11.4. Alternative Protocols

Linking to other web pages using the HTTP protocol is by far the most common type of link, but there are several other types of transactions that can be made using other standard Internet protocols.

11.4.1. Mail Link (mailto:)

The mailto protocol can be used in an a element to automatically send an email message to the recipient, using the browser's email application or an external email application. Note that the browser must be configured to support this protocol, so it will not work for all users. The mailto protocol has the following components:

 mailto:username@domain 

A typical mail link might look like this:

 <a href="mailto:jen@oreilly.com">Send Jennifer email</a> 

You can also experiment with adding information within the mailto URL that automatically fills in standard email fields such as Subject or cc:.

 mailto:username@domain?subject=subject 

 mailto:username@domain?cc=person1 

 mailto:username@domain?bcc=person2 

 mailto:username@domain?body=body 

Additional variables are appended to the string with an ampersand (&) symbol as shown:

 mailto:username@domain?subject=subject&cc=person1&body=body 

In XHTML, the ampersand (&) symbol must be escapedthat is, expressed as a character entity (&amp;) in the stringfor the document to be valid. The same link in XHTML would be marked up like this:

 mailto:username@domain?subject=subject&amp;cc=person1&body=body 

Spaces within subject lines need to be written as %20 (the space character in hexadecimal notation). The following sample mail link employs these additions:

     <a href="mailto:jen@oreilly.com?subject=Like%20your%20book">Email for     Jen</a> 

When you put a link to an email address on a web page, the address is prone to getting "spidered" (automatically indexed) and added to spam mailing lists. To avoid getting spammed, do not put your intact email address in the source document, either as a mailto link or in the content itself. An alternative is to spell out the email address (such as "jen at oreilly dot com") so it is understandable to humans but not recognizable to spambots.


11.4.2. FTP Link (ftp://)

You can link directly to a file on an FTP server. When the user clicks on the link, the file downloads automatically using the browser's built-in FTP functions and is saved on the user's machine. If the document is on an anonymous FTP server (no account name and password are required), the FTP link is simple:

 <a href="ftp://server/pathname">...</a> 

To link to an FTP server that requires the user to log in, the format is:

 <a href="ftp://user:password@server/pathname">...</a> 

For security purposes, it is highly recommended that you never include both the username and password to a server within an HTML document. If you use the syntax user@server/path, the users will be prompted to enter their passwords in a dialog box.

By default, the requested file is transferred in binary format. To specify that the document should be transferred as an ASCII file, add ;type=a to the end of the URL:

 <a href="ftp://user:password@server/pathname;type=a">...</a> 

The variable type=d identifies the pathname as a directory and simply displays its contents in the browser window. The variable type=i specifies image or binary mode, which is the default but may also be given explicitly.

Here are some examples of FTP links:

 <a href="ftp://pete@ftp.someserver.com/program.exe">...</a> 

 <a href="ftp://ftp.superwarehouse.com/games;type=d">...</a> 

11.4.3. Other Links

Table 11-1 lists URL types that are not as well known or useful as mailto or ftp://, but are available. As with other links, place these URLs after the href attribute within the anchor element.

Table 11-1. Alternative link protocols

Type

Syntax

Use

File

file://server/path

Specifies a file without indicating the protocol. This is useful for accessing files on a contained site such as a CD-ROM or kiosk application, but it is less appropriate over networks (such as the Internet).

News

news:newsgroup

news:message_id

Accesses either a single message or an entire newsgroup within the Usenet news system. Some browsers do not support news URLs, so you should avoid using them.

NNTP

nntp://server:port/newsgroup/article

Provides a complete mechanism for accessing Usenet news articles. The article is served only to machines that are allowed to retrieve articles from this server, so this URL has limited practical use.

Telnet

telnet://user:password@server:port/

Opens a Telnet session with a desired server. The user and password@ elements are optional and follow the same rules as described for ftp://.

Gopher

gopher://server:port/path

Accesses a document on a gopher server. The gopher document retrieval system was eclipsed by the World Wide Web, but some gopher servers are still operating.





Web Design in a Nutshell
Web Design in a Nutshell: A Desktop Quick Reference (In a Nutshell (OReilly))
ISBN: 0596009879
EAN: 2147483647
Year: 2006
Pages: 325

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