此方法創建一個用作超文本目標的HTML錨。
語法
string.anchor( anchorname )
下麵是參數的詳細資訊:
-
anchorname: 定義了錨的名稱
返回值:
-
返回其錨標記的字串
例子:
<html>
<head>
<title>JavaScript String anchor() Method</title>
</head>
<body>
<script type="text/javascript">
var str = new String("Hello world");
alert(str.anchor( "myanchor" ));
</script>
</body>
</html>
這將產生以下結果:
<a name="myanchor">Hello world</a>
