aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/svgaelement/index.html
blob: a721383b9246212dafd51142d762c1807f625d1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
title: SVGAElement
slug: Web/API/SVGAElement
tags:
  - API
  - SVG
  - SVG DOM
  - WebAPI
  - 参考
  - 需要兼容性表
  - 需要示例
translation_of: Web/API/SVGAElement
---
<div>{{APIRef("SVG")}}</div>

<h2 id="SVG_a_DOM_接口">SVG a DOM 接口</h2>

<p><code>SVGAElement</code>接口提供了对{{ SVGElement("a") }}元素的属性的访问,而且还提供了操作该元素的方法。</p>

<h3 id="接口概览">接口概览</h3>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="row">又作用于</th>
   <td>{{ domxref("SVGElement") }}{{ domxref("SVGURIReference") }}{{ domxref("SVGTests") }}{{ domxref("SVGLangSpace") }}{{ domxref("SVGExternalResourcesRequired") }}{{ domxref("SVGStylable") }}{{ domxref("SVGTransformable") }}</td>
  </tr>
  <tr>
   <th scope="row">方法</th>
   <td><em></em></td>
  </tr>
  <tr>
   <th scope="row">属性</th>
   <td>
    <ul>
     <li>只读属性 {{ domxref("SVGAnimatedString") }} <code>target</code></li>
    </ul>
   </td>
  </tr>
  <tr>
   <th scope="row">规范文档</th>
   <td><a class="external" href="http://www.w3.org/TR/SVG11/linking.html#InterfaceSVGAElement">SVG 1.1 (2nd Edition)</a></td>
  </tr>
 </tbody>
</table>

<h2 id="属性">属性</h2>

<p>这个接口同样会从父级元素 <em>{{domxref("SVGGraphicsElement")}}</em>继承属性,并实现 <em>{{domxref("SVGURIReference")}}</em><em>{{domxref("HTMLHyperlinkElementUtils")}}</em> 中的功能。</p>

<p><strong>{{domxref("SVGAElement.download")}} </strong></p>

<p>    参见 {{domxref("HTMLAnchorElement.download")}}</p>

<p><strong>{{domxref("SVGAElement.href")}} </strong></p>

<p>    See {{domxref("HTMLAnchorElement.href")}}</p>

<p><strong>{{domxref("SVGAElement.hreflang")}} </strong></p>

<p>    是一个反映 <code>hreflang</code> 属性的字符串( DOMString ),表示链接资源的语言种类。</p>

<p><strong>{{domxref("SVGAElement.ping")}} </strong></p>

<p>    是一个反映ping值的字符串( DOMString ),包含以空格分隔开的URL列表,当超链接可以被跟踪时,浏览器会(在后台)发送有PING主体的 {{HTTPMethod("POST")}} 的请求,一般用于追踪。</p>

<p><strong>{{domxref("SVGAElement.referrerPolicy")}} </strong></p>

<p>    参见 {{domxref("HTMLAnchorElement.referrerPolicy")}}</p>

<p><strong>{{domxref("SVGAElement.rel")}} </strong></p>

<p><strong>    </strong>参见 {{domxref("HTMLAnchorElement.rel")}}</p>

<p><strong>{{domxref("SVGAElement.relList")}} </strong></p>

<p>    参见{{domxref("HTMLAnchorElement.relList")}}</p>

<p><strong>{{domxref("SVGAElement.target")}} {{readonlyInline}} </strong></p>

<p><strong>  </strong>  它和特定元素的 {{SVGAttr("target")}} 属性相同</p>

<p><strong>{{domxref("SVGAElement.text")}} </strong></p>

<p>    是一个字符串( DOMString ),作为 {{domxref("Node.textContent")}} 属性的代名词。</p>

<p><strong>{{domxref("SVGAElement.type")}} </strong></p>

<p>    是一个反映 <code>type</code> 属性的字符串( DOMString ),表示链接资源的MIME种类。</p>

<h2 id="方法">方法</h2>

<p><code><font face="Open Sans, Arial, sans-serif"></font>SVGAElement接口没有提供任何专有的方法。</code></p>

<h2 id="示例">示例</h2>

<p>在下面的这个例子里, {{SVGElement("a")}} 元素的 {{SVGAttr("target")}} 属性值是 <code>_blank</code> ,当链接被点击时,它将记录以通知是否符合条件。</p>

<pre class="brush: js"><code class="language-js"><span class="keyword token">var</span> linkRef <span class="operator token">=</span> document<span class="punctuation token">.</span><span class="function token">querySelector</span><span class="punctuation token">(</span><span class="string token">"a"</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
linkRef<span class="punctuation token">.</span>target <span class="operator token">=</span> <span class="string token">"_self"</span><span class="punctuation token">;</span> </code>

linkRef<span class="punctuation token">.</span><span class="function function-variable token">onclick</span> <span class="operator token">=</span> <span class="keyword token">function</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">{</span>
  <span class="keyword token">if</span> <span class="punctuation token">(</span>linkRef<span class="punctuation token">.</span>target <span class="operator token">===</span> <span class="string token">"_blank"</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
    console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"BLANK!"</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
    linkRef<span class="punctuation token">.</span>target <span class="operator token">=</span> <span class="string token">"_self"</span><span class="punctuation token">;</span>
  <span class="punctuation token">}</span> <span class="keyword token">else</span> <span class="punctuation token">{</span>
    console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span><span class="string token">"SORRY! not _blank"</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
  <span class="punctuation token">}</span>
<span class="punctuation token">}</span></pre>

<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>

{{Compat("api.SVGAElement")}}

<h2 id="参见">参见</h2>

<ul>
 <li>{{ SVGElement("a") }} SVG Element</li>
</ul>