Javascript-string-anchor

提供:Dev Guides
移動先:案内検索

JavaScript文字列-anchor()メソッド

説明

このメソッドは、ハイパーテキストターゲットとして使用される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>