class

Doc

@Js
class Doc : Obj

Doc models the DOM document object.

See pod doc for details.

fields title

The title of this document

methods removeEvent

Remove the given event handler from this document

querySelectorAll

Returns a list of the elements within the document (using depth-first pre-order traversal of the document's nodes) that match the specified group of selectors

elemsFromPos

Get a list of all elements at the specified coordinates (relative to the viewport)

querySelector

Returns the first element within the document (using depth-first pre-order traversal of the document's nodes) that matches the specified group of selectors, or null if none found

body

Get the body element

cookies

Map of cookie values keyed by cookie name

out

Return a WebOutStream for writing content into this document

head

Get the head element

elemById

Get the element with this id, or null if no element is found with this id

addCookie

Add a cookie to this session

onEvent

Attach an event handler for the given event on this document

activeElem

Get the currently focused element, or null for none

elemFromPos

Get the topmost element at the specified coordinates (relative to the viewport), or null if none found

hasFocus

Return true if this document or any element inside the document has focus

createElem

Create a new element with the given tag name

exec

When a HTML document has been switched to designMode, the document object exposes the exec method which allows one to run commands to manipulate the contents of the editable region

activeElem Elem? activeElem()

Get the currently focused element, or null for none.

addCookie Void addCookie(Cookie c)

Add a cookie to this session.

body Elem body()

Get the body element.

cookies Str:Str cookies()

Map of cookie values keyed by cookie name. The cookies map is readonly and case insensitive.

createElem Elem createElem(Str tagName, [Str:Str]? attrib, Uri? ns)

Create a new element with the given tag name. If the attrib map is specified, set the new elements attributes to the given values. Optionally a namespace for the element can be specified with ns.

elemById Elem? elemById(Str id)

Get the element with this id, or null if no element is found with this id.

elemFromPos Elem? elemFromPos(Point p)

Get the topmost element at the specified coordinates (relative to the viewport), or null if none found.

elemsFromPos Elem[] elemsFromPos(Point p)

Get a list of all elements at the specified coordinates (relative to the viewport). The elements are ordered from the topmost to the bottommost box of the viewport.

exec Bool exec(Str name, Bool defUi, Obj? val)

When a HTML document has been switched to designMode, the document object exposes the exec method which allows one to run commands to manipulate the contents of the editable region.

  • name: the command name to execute
  • defUi: flag to indicate if default user interface is shown
  • val: optional value for commands that take an argument

hasFocus Bool hasFocus()

Return true if this document or any element inside the document has focus.

head Elem head()

Get the head element.

onEvent Func onEvent(Str type, Bool useCapture, |Event| handler)

Attach an event handler for the given event on this document. Returns callback function instance.

out WebOutStream out()

Return a WebOutStream for writing content into this document. You should call close on the stream when done writing to notify browser load is complete.

querySelector Elem? querySelector(Str selectors)

Returns the first element within the document (using depth-first pre-order traversal of the document's nodes) that matches the specified group of selectors, or null if none found.

querySelectorAll Elem[] querySelectorAll(Str selectors)

Returns a list of the elements within the document (using depth-first pre-order traversal of the document's nodes) that match the specified group of selectors.

removeEvent Void removeEvent(Str type, Bool useCapture, Func handler)

Remove the given event handler from this document. If this handler was not registered, this method does nothing.

title Str : title

The title of this document.

Haxall 4.0.5 ∙ 24-Feb-2026 14:33 EST