返回到:JavaScript对象:JavaScript String 对象
定义和用法
link() 方法用于把字符串显示为超链接。
该方法返回加了 <a> 标签的字符串, 如下所示:
<a href=”url”>string</a>
语法
string.link(url)
参数 | 描述 |
---|---|
url | Required. The URL to link to |
所有主要浏览器都支持 link() 方法。
实例
将字符串 “Free Web Building Tutorials!”显示为链接:
HTML
x
26
26
1
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>Web176教程(Web176.com)</title>
6
</head>
7
<body>
8
9
<script>
10
var txt = "Hello Web176!";
11
document.write("<p>字体变大: " + txt.big() + "</p>");
12
document.write("<p>字体缩小: " + txt.small() + "</p>");
13
document.write("<p>字体加粗: " + txt.bold() + "</p>");
14
document.write("<p>斜体: " + txt.italics() + "</p>");
15
document.write("<p>固定定位: " + txt.fixed() + "</p>");
16
document.write("<p>加删除线: " + txt.strike() + "</p>");
17
document.write("<p>字体颜色: " + txt.fontcolor("green") + "</p>");
18
document.write("<p>字体大小: " + txt.fontsize(6) + "</p>");
19
document.write("<p>下标: " + txt.sub() + "</p>");
20
document.write("<p>上标: " + txt.sup() + "</p>");
21
document.write("<p>链接: " + txt.link("https://www.Web176.com") + "</p>");
22
document.write("<p>闪动文本: " + txt.blink() + " (不能用于IE,Chrome,或者Safari)</p>");
23
</script>
24
25
</body>
26
</html>
阅读剩余 45%
作者:terry,如若转载,请注明出处:https://www.web176.com/javascriptbook/jsarrtips/3091.html