Creating Links

The link procedures enable you to create links and link anchors. When a user clicks a link, the web browser switches to the top of the specified HTML document, to a point within the specified document, or to a link anchor within the same document. A link can point to the home page of a website, for example.

To insert a link, use the html_a procedure to format the information that is to become the link, and use the html_a_end procedure to mark the end of the link. Two useful attributes for the html_a procedure are the HREF and NAME attributes:

  • Use the HREF attribute to specify the location to which the link points.

  • Use the NAME attribute to specify an anchor to which a link can point.

These attributes are passed as arguments to the html_a procedure.

The following code example creates an anchor and two links. The anchor is positioned at the top of the document. The first link points to the HTML home.html document. The second link points to the anchor named TOP in the current document. Note the # sign in the argument, which indicates that the named anchor is a point within a document. The third link points to an anchor named POINT1 in the mydoc.html document.

do html_a('HREF=home.html')
print 'Goto home page' ()
do html_a_end

do html_a('NAME=TOP')
do html_a_end

print 'At the top of document' ()
do html_br(40, '')
print 'At the bottom of document' ()
do html_p('')

do html_a('HREF=#TOP')
print 'Goto top of document' ()
do html_a_end

do html_a ('HREF=mydoc.html#POINT1')
print 'Goto point1 in mydoc.html' ()
do html_a_end