JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

String.anchor() Method

Name

String.anchor() Method---add an HTML anchor to a string

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

string.anchor(name)

Arguments

name

The value of the NAME attribute of the HTML <A> tag, i.e., the name of the anchor to be created.

Returns

A copy of string, enclosed within <A NAME="name"> and </A> HTML tags.

Description

String.anchor() returns a copy of the string for which it is called, surrounded by <A> and </A> HTML tags. The NAME attribute of the <A> tag is set to the name argument. If the resulting string is appended to an HTML document (with Document.write() for example), it defines an anchor, with a name of name, which can be the target of a hypertext link.

Example

The following two JavaScript fragments evaluate to identical strings:

'Chapter 1: Introduction'.anchor('ch01');'
'<A NAME="ch01">Chapter 1: Introduction</A>'

See Also

"String", "String.link()"


Previous Home Next
String Book Index String.big()

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
This HTML Help has been published using the chm2web software.