Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
Summary
Creates an HTML anchor that is used as a hypertext target.
Method of String |
|
|---|---|
| Implemented in | JavaScript 1.0 |
| ECMAScript Edition | none |
Syntax
anchor(nameAttribute)
Parameters
-
nameAttribute - A string.
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. Firefox 17 In strings supplied for the nameAttribute the " (quotation mark) is replaced by its HTML reference character ".
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.
Examples
Example: Using anchor
The following example code within an HTML script element:
var myString = "Table of Contents";
document.body.innerHTML = myString.anchor("contents_anchor");
will output the following HTML:
<A NAME="contents_anchor">Table of Contents</A>
Mozilla Developer Network