anchor()

优质
小牛编辑
114浏览
2023-12-01

描述 (Description)

此方法创建一个用作超文本目标的HTML锚点。

语法 (Syntax)

其语法如下 -

string.anchor( anchorname )

属性细节

anchorname - 定义锚点的名称。

返回值 (Return Value)

返回具有锚标记的字符串。

例子 (Example)

请尝试以下示例。

<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>

输出 (Output)

<a name="myanchor">Hello world</a>