|
Links to Other Documents
| [Previous] [Main] [Next] |
|
| |
| The htmlHyperLink class provides several different constructors, making full description of a hyperlink object in a single statement both easy and convenient.
| |
|
| |
| There are two types of hyperlinks to other documents: local and remote.
| |
|
| |
| URL's for remote documents are generally of the form:
| |
|
| |
| http://www.domainname.com/path/document.html
| |
|
| |
| where "http://" indicates the HTTP protocol, which is standard for web documents. Other protocols include "ftp://" (file transfer protocol) and "mailto:" (for email). The "www.domainname.com" portion specifies the name of the server. The "path" portion indicates the pathname of the document relative to the server's root (starting) path, and is optional. The actual document name (in this case, "document.html") completes the URL.
| |
|
| |
| URL's for local documents are nearly identical, except that they omit the protocol and server name:
| |
|
| |
| /path/document.html
| |
|
| |
| Local URL's can also include relative path specifiers such as "." and "..".
| |
|
| |
| There are several ways to use htmlHyperLink to create hyperlinks to local or remote documents. The following snippets are all functionally equivalent:
| |
|
| |
| htmlHyperLink h ;
| |
| h.URL( "http://www.dcmicro.com/index.html" )
| |
| h << "Click here for DC Micro's home page." ) ;
| |
|
| |
| htmlHyperLink h( "http://www.dcmicro.com/index.html" ) ;
| |
| h << "Click here for DC Micro's home page." ) ;
| |
|
| |
| htmlHyperLink h( "http://www.dcmicro.com/index.html",
| |
| "Click here for DC Micro's home page." ) ;
| |
|
| |
| Each of the above object declarations produces the following HTML code when output to a page:
| |
|
| |
| <A HREF="http://www.dcmicro.com/index.html">Click here for DC Micro's home page.</A>
| |
|
| |
|
| |
