Confirmed users
1,396
edits
(→Text) |
|||
Line 1,045: | Line 1,045: | ||
<pre> | <pre> | ||
partial interface AccessiblePos { | partial interface AccessiblePos { | ||
DOMString | DOMString text(AccessiblePos pos); | ||
DOMString text(CriteriaLiteral criteria); | |||
readonly attribute AttributeSet textAttributes; | readonly attribute AttributeSet textAttributes; | ||
}; | }; | ||
Line 1,051: | Line 1,052: | ||
<code> | <code> | ||
AccessibleDocument .'' | AccessibleDocument .''text'' | ||
::Returns the text enclosed between this and given accessible positions. | ::Returns the text enclosed between this and given accessible positions. | ||
AccessibleDocument .''text'' | |||
::Returns the text at the position complying the given criteria. See [[#Criteria|criteria]] for options. | |||
</code> | </code> | ||
Example how to get first line of the first encountered paragraph: | Example how to get first line of the first encountered paragraph: | ||
<pre> | <pre> | ||
var startPos = new A11ePos().move("first", | function criteria(a) | ||
var endPos = startPos && startPos.search("forward", | { return a.role == "paragraph" ? "being" : "next" }; | ||
var text = startPos. | var startPos = new A11ePos(document).move("first", criteria); | ||
var endPos = startPos && startPos.search("forward", "line"); | |||
var text = startPos.text(startPos, endPos); | |||
</pre> | |||
or same effect by using criteria literal | |||
<pre> | |||
function criteria(a) | |||
{ return a.role == "paragraph" ? "being" : "next" }; | |||
var pos = new A11ePos(document).move("first", criteria); | |||
var text = pos.text("line"); | |||
</pre> | </pre> | ||