Core JavaScript 1.5 Reference:Global Objects:String:anchor
From MDC
Non-standard
Contents |
[edit] Summary
Creates an HTML anchor that is used as a hypertext target.
| Method of String | |
| Implemented in: | JavaScript 1.0, NES2.0 |
[edit] Syntax
anchor(nameAttribute)
[edit] Parameters
-
nameAttribute - A string.
[edit] Description
Use the anchor method with the document.write or document.writeln methods to programmatically create and display an anchor in a document. Create the anchor with the anchor method, and then call write or writeln to display the anchor in a document. In server-side JavaScript, use the write function to display the anchor.
In the syntax, the text string represents the literal text that you want the user to see. The nameAttribute string represents the NAME attribute of the A tag.
Anchors created with the anchor method become elements in the document.anchors array.
[edit] Examples
[edit] Example: Using anchor
The following example code within an HTML script element:
var myString = "Table of Contents";
document.writeln(myString.anchor("contents_anchor"));
will output the following HTML:
<A NAME="contents_anchor">Table of Contents</A>