Documentation/HtmlDocument
class

HtmlDocument

js/foo_uie_jsplitter.js:5275

Object returned by utils.ParseHtml

Lightweight DOM-like HTML document backed by the native HTML parser.

Notes:
- This is not a full browser DOM.
- Scripts, CSS, layout, external resources and browser events are not processed.
- innerText is currently an alias of textContent.

propertyreadonly

body

js/foo_uie_jsplitter.js:5325
body: ?HtmlNode

The document <body> element.

Example

let doc = utils.ParseHtml("<html><body><p>Hello</p></body></html>");
if (doc && doc.body) console.log(doc.body.innerHTML); // "<p>Hello</p>"
propertyreadonly

documentElement

js/foo_uie_jsplitter.js:5301
documentElement: ?HtmlNode

Root document element, usually the <html> element.

Example

let doc = utils.ParseHtml("<html><body>Hello</body></html>");
if (doc) console.log(doc.documentElement.tagName); // "html"
propertyreadonly

innerHTML

js/foo_uie_jsplitter.js:5360
innerHTML: string

Serialized HTML markup inside the document body.
If the document has no body, this falls back to the root element.

Example

let doc = utils.ParseHtml("<html><body><p>Hello <b>world</b></p></body></html>");
if (doc) console.log(doc.innerHTML); // "<p>Hello <b>world</b></p>"
propertyreadonly

innerText

js/foo_uie_jsplitter.js:5351
innerText: string

Alias of textContent.
Since this parser has no browser layout engine, innerText does not emulate CSS visibility, rendered line wrapping, or layout-dependent text extraction.

propertyreadonly

outerHTML

js/foo_uie_jsplitter.js:5373
outerHTML: string

Serialized outer HTML of the root element.

Example

let doc = utils.ParseHtml("<html><body><p>Hello</p></body></html>");
if (doc) console.log(doc.outerHTML); // "<html><head></head><body><p>Hello</p></body></html>"
propertyreadonly

root

js/foo_uie_jsplitter.js:5288
root: ?HtmlNode

Root document element, usually the <html> element.
Alias of documentElement.

Example

let doc = utils.ParseHtml("<html><body>Hello</body></html>");
if (doc) console.log(doc.root.tagName); // "html"
propertyreadonly

textContent

js/foo_uie_jsplitter.js:5337
textContent: string

Text content of the document body.
If the document has no body, this falls back to the root element text.
Whitespace is returned as it exists in the parsed text nodes.

Example

let doc = utils.ParseHtml("<html><body><p>Hello <b>world</b></p></body></html>");
if (doc) console.log(doc.textContent); // "Hello world"
method

getElementsByTagName

js/foo_uie_jsplitter.js:5414
getElementsByTagName(tagName)

Returns all descendant elements with the specified tag name.
Use "*" to return all descendant elements.

Parameters

NameTypeDescription
tagNamestring

Tag name, for example "a", "div", "section" or "*".

Returns

Array<HtmlNode>

Array of matching nodes. Empty array if nothing matches.

Example

const doc = utils.ParseHtml("<p><a href='https://example.com'>Link</a></p>");
const links = doc ? doc.getElementsByTagName("a") : [];
console.log(links.length); // 1
method

querySelector

js/foo_uie_jsplitter.js:5385
querySelector(selector)

Returns the first element matching a CSS selector.

Parameters

NameTypeDescription
selectorstring

CSS selector.

Returns

?HtmlNode

First matching node, or null if nothing matches.

Example

let doc = utils.ParseHtml("<html><body><p class='name'>Test Artist</p></body></html>");
let node = doc ? doc.querySelector(".name") : null;
if (node) console.log(node.textContent); // "Test Artist"
method

querySelectorAll

js/foo_uie_jsplitter.js:5399
querySelectorAll(selector)

Returns all elements matching a CSS selector.
The returned value is a regular JavaScript array.

Parameters

NameTypeDescription
selectorstring

CSS selector.

Returns

Array<HtmlNode>

Array of matching nodes. Empty array if nothing matches.

Example

let doc = utils.ParseHtml("<ul><li class='album'>A</li><li class='album'>B</li></ul>");
let albums = doc ? doc.querySelectorAll(".album") : [];
console.log(albums.length); // 2