blob: 75b44934a1f728a3038401af1cff65d139fb171c (
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
|
---
title: Range.endOffset
slug: Web/API/Range/endOffset
tags:
- API
- DOM
- Range
- 属性
translation_of: Web/API/Range/endOffset
---
<div>{{ApiRef("DOM")}}</div>
<p><span style="line-height: 1.5;">只读属性</span> <code><strong>Range.endOffset</strong></code> 返回代表<span style="line-height: 1.5;"> </span><code style="font-style: normal; line-height: 1.5;">Range</code><span style="line-height: 1.5;"> 结束位置在 </span>{{domxref("Range.endContainer")}} <span style="line-height: 1.5;">中的偏移值的数字。</span></p>
<p>如果 <code>endContainer</code> 的 {{domxref("Node")}} 类型为 {{domxref("Text")}}, {{domxref("Comment")}},或 {{domxref("CDATASection")}},偏移值是 <code>endContainer</code> 节点开头到 {{domxref("Range")}} 末尾的总字符个数。对其他类型的 {{domxref("Node")}} , <code>endOffset</code> 指 <code>endContainer</code> 开头到 {{domxref("Range")}} 末尾的总 {{domxref("Node")}} 个数。如需修改 <code>endOffset</code> 的值, 使用 {{domxref("Range.setEnd")}} 方法。</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="syntaxbox"><em>endRangeOffset</em> = <em>range</em>.endOffset;
</pre>
<h2 id="Example" name="Example">示例</h2>
<pre class="brush:js">var range = document.createRange();
range.setStart(startNode,startOffset);
range.setEnd(endNode,endOffset);
endRangeOffset = range.endOffset;</pre>
<h2 id="Specification" name="Specification">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('DOM WHATWG', '#dom-range-endoffset', 'Range.endOffset')}}</td>
<td>{{Spec2('DOM WHATWG')}}</td>
<td>No change.</td>
</tr>
<tr>
<td>{{SpecName('DOM2 Traversal_Range', 'ranges.html#Level-2-Range-attr-endOffset', 'Range.endOffset')}}</td>
<td>{{Spec2('DOM2 Traversal_Range')}}</td>
<td>Initial specification.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.Range.endOffset")}}</p>
<h2 id="参见">参见</h2>
<ul>
<li><a href="/en-US/docs/DOM/DOM_Reference" title="/en-US/docs/DOM/DOM_Reference">The DOM interfaces index</a></li>
</ul>
|