Class: Document

html.Document

Class representing the root document.

new html.Document ()

Properties:
Name Type Description
active bool

[readonly] Whether the document is currently active (the window and tab have focus).

bbox object

[readonly] The current bounding box.

bboxX number

[readonly] The document's bounding box X position in window coordinates.

bboxY number

[readonly] The document's bounding box Y position in window coordinates.

bboxWidth number

[readonly] The document's bounding box width in window coordinates.

bboxHeight number

[readonly] The document's bounding box height in window coordinates.

color string

The document's background color.

contentHeight number

[readonly] The current scrolling viewport height.

contentWidth number

[readonly] The current scrolling viewport width.

contentX number

(default: 0) The current horizontal scrolling position.

contentY number

(default: 0) The current vertical scrolling position.

fullscreenItem html.Item

(default: null) The current item shown in fullscreen mode.

inputDevice string

[readonly] The currently active input device: mouse|touch|pen|keyboard

maxHttpRequests number

(default: 4) The maximum number of simultaneous HTTP requests.

scrollbars bool

(default: false) Whether to show native scrollbars.

systemDarkMode bool

[readonly] Whether the system is in dark mode (Windows 10, MacOS, Android).

title string

The document's title.

windowWidth number

[readonly] Deprecated: Use bboxWidth instead. The current width of the document window.

windowHeight number

[readonly] Deprecated: Use bboxHeight instead. The current height of the document window.

Extends

Methods

httpRequest (url, method)HttpRequest

Creates and returns an asynchronous HTTP request with progress monitoring. The maximum number of simultaneous requests is determined by the property maxHttpRequests.

Example

httpRequest("/path/to/resource")
.send()
.then(response => response.text())
.then(data =>
{
  console.log("Got data: " + data);
})
.catch(err => { console.error(err); }

Example

httpRequest("/path/to/resource", "POST")
.header("X-Custom-Header", "42")
.body(new Blob(["Some data"]))
.send(p => console.log("upload progress: " + p);

Example

httpRequest("/path/to/large.file")
.send(null, p => console.log("download progress: " + p);
Name Type Description
url string

The request URL.

method string

(default: "GET") The HTTP method.

Returns:
Type Description
HttpRequest The request object.

inView (x, y, w, h)

Returns whether the given box is (partially) within the viewport. The coordinates are in this element's local coordinate system.

Name Type Description
x number

The X position to test.

y number

The Y position to test.

w number

The width to test.

h number

The height to test.

Type Definitions

html.Document.Event

A generic event.

Events

html.Document.event:contextMenu

Is triggered when the browser context menu is requested. Binding to this event and accepting it prevents the default context menu from showing up.

Name Type Description
event html.Document.Event

The event object.

html.Document.event:keyDown

Is triggered when a key is pressed while the document has keyboard focus.

Name Type Description
event html.Item.KeyboardEvent

The event object.

html.Document.event:keyUp

Is triggered when a key is released while the item has keyboard focus.

Name Type Description
event html.Item.KeyboardEvent

The event object.