Method XbpHTMLViewer2():queryAllByClass() Foundation

Gets all HTML elements given a certain CSS class.

Syntax
:queryAllByClass( <cClass> ) --> oAsyncResult
Parameters
<cClass>
The CSS class name or names that must be set for the HTML elements. If more than one class name is to be included in the query, the names must be separated with a whitespace.
Return

A AsyncResult() object which can be used to wait for the query operation to complete, and for retrieving the operation result. The operation result is an array of DataObjects, one for each matching node in the DOM tree. If no element matched the query, return is the empty array ({}). If the method fails, the returned AsyncResult object will be in error state. Use :error() to determine more information about the error.

The returned data objects at least have the members :nodeName, :nodeValue, :attributes, :childNodeCount and :children. Attributes are returned as members of a data object in :attributes, with the attribute values stored in a member with the same name as the attribute.

Description

The method :queryAllByClass() returns information about all HTML elements that have specific CSS class(es) set in their "class" attributes.

If matching HTML elements are found, :queryAllByClass() returns read-only representations of these HTML elements as the operation result. This can be used to check for the existence of certain HTML elements as well as for examining attribute values. Changing page elements via the operation result is not possible. Use :executeScript() or some other means to achieve this.

:queryAllByClass() executes asynchronously in the context of the current page. The page must be fully loaded and the DOM (document object model) tree must be stable for the method to function properly. If the HTML viewer is currently in the process of navigating to another page, for example, querying the DOM tree may fail or produce unexpected results. In this case, use the result object returned by :navigate() or the :navigateComplete() event to wait for navigation to complete before performing the query. To immediately retrieve the operation result, use the :get() method of the AsyncResult() object returned by :queryAllByClass().

See the method :queryByClass() for a usage example.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.