Accessibility/WebAccessibilityAPI: Difference between revisions

Jump to navigation Jump to search
Line 1,045: Line 1,045:
<pre>
<pre>
partial interface AccessiblePos {
partial interface AccessiblePos {
   DOMString textInBetween(AccessiblePos pos);
   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 .''textInBetween''
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", a => a.role == "paragraph");
function criteria(a)
var endPos = startPos && startPos.search("forward", a => [ "line", "stop" ]);
  { return a.role == "paragraph" ? "being" : "next" };
var text = startPos.textInBeetween(startPos, endPos);
var startPos = new A11ePos(document).move("first", criteria);
var endPos = startPos && startPos.search("forward", "line");
var text = startPos.text(startPos, endPos);
</pre>


say(text);
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>


Confirmed users
1,396

edits

Navigation menu