Help Center

Local Navigation

Object: HTMLDocument

Availability

BlackBerry® Device Software version 3.8 or later

Extends

Document

The HTMLDocument object provides access to the HTML hierarchy.

HTMLDocument properties

Property name

Type

Description

Status

Availability

anchors

HTMLCollection

Returns an index of the <a> elements contained within the document. Index positions begin at 0 and continue to HTMLCollection.length-1.

read only

3.8 or later

applets

HTMLCollection

Returns an index of the <applet> elements and <object> elements containing applets contained within the document. Index positions begin at 0 and continue to HTMLCollection.length -1.

read only

3.8 or later

body

HTMLElement

Returns the element that contains the content of the document. In documents with <body> elements, returns the <body> element. In frameset documents, returns the outermost <frameset> element.

This property is writable. However, be aware that specifying a new value for this property effectively removes all the renderable content of the document.

writable

3.8 or later

compatMode

String

Returns whether or not this document is rendered in strict mode. A value of “CSS1Compat” indicates strict mode is enforced. A value of “BackCompat” indicates that strict mode is not enforced.

read only

3.8 or later

cookie

String

When the BlackBerry® Browser reads this property, it returns a semicolon-separated list of the name-value pairs of all visible and unexpired cookies associated with the document or frame.

When you set a value for this property, each new value must be a single name-value pair followed by zero or more cookie attributes. If the specified name is already associated with a cookie, the new value and attributes replace the old value and attributes.

If the value you specify does not adhere to correct cookie syntax, this property throws a SYNTAX_ERR.

writable

3.8 or later

domain

String

Specifies the domain name from which the document was served.

writable

3.8 or later

forms

HTMLCollection

Returns an index of the <form> elements contained within the document. Index positions begin at 0 and continue to HTMLCollection.length -1.

read only

3.8 or later

images

HTMLCollection

Returns an index of the <img> elements contained within the document. Index positions begin at 0 and continue to HTMLCollection.length -1.

read only

3.8 or later

links

HTMLCollection

Returns an index of the <link> elements contained in the document. Index positions begin at 0 and continue to HTMLCollection.length -1.

read only

3.8 or later

location

Location

Specifies information about the URI of the document.

writable

3.8 or later

referrer

String

Returns the URL of the document that linked to the active document.

read only

3.8 or later

title

String

Specifies the text contained within the <title> element of the active document.

writable

3.8 or later

URL

String

Returns the complete URL of the active document.

read only

3.8 or later

HTMLDocument event handlers

Property name

Type

Description

Status

Availability

onblur

EventListener

Specifies the function to perform when an element loses focus by either the pointer or by tabbed navigation.

writable

4.6 or later

onchange

EventListener

Specifies the function to perform when a form control loses focus after the user has modified the value.

writable

4.6 or later

onclick

EventListener

Specifies the function to perform when the user clicks the trackball or trackwheel on a BlackBerry® device.

writable

3.8 or later

onfocus

EventListener

Specifies the function to perform when an element gains focus by either the pointer or by tabbed navigation.

writable

4.6 or later

onkeydown

EventListener

Specifies the function to perform when a key is pressed down while the pointer is over an element.

writable

4.6 or later

onkeypress

EventListener

Specifies the function to perform when a key is pressed and released while the pointer is over an element.

writable

4.6 or later

onkeyup

EventListener

Specifies the function to perform when a key is released while the pointer is over an element.

writable

4.6 or later

onmousedown

EventListener

Specifies the function to perform when the user depresses the trackwheel or trackball on a BlackBerry device.

writable

3.8 or later

onmousemove

EventListener

Specifies the function to perform when the user moves the pointer over an element.

writable

4.6 or later

onmouseout

EventListener

Specifies the function to perform when the user moves the pointer off of an element.

writable

4.6 or later

onmouseover

EventListener

Specifies the function to perform when the user moves the pointer over an element.

writable

4.6 or later

onmouseup

EventListener

Specifies the function to perform when the user releases the trackwheel or trackball on a BlackBerry device.

writable

4.6 or later

onreset

EventListener

Specifies the function to perform when the user resets a form.

writable

3.8 or later

onselect

EventListener

Specifies the function to perform when the user selects some text in a text field.

writable

4.6 or later

onsubmit

EventListener

Specifies the function to perform when the user submits a form.

writable

3.8 or later

HTMLDocument methods

Method name

Description

Availability

close()

Closes the document opened by HTMLDocument.open() and forces rendering.

3.8 or later

getElementByName()

Returns an array of all the elements in the document with the specified name.

4.6 or later

open()

Opens a document stream for writing.

3.8 or later

write()

Writes a string of text to a document stream opened by HTMLDocument.open().

3.8 or later

writeln()

Writes a string of text, followed by a new line character to a document stream opened by HTMLDocument.open().

3.8 or later

Method: HTMLDocument.close()

Availability

BlackBerry® Device Software version 3.8 or later

The close() method closes the document opened by HTMLDocument.open() and forces rendering.

Syntax

HTMLDocument.close()

Parameters

None.

Return values

None.

Exceptions

None.

Method: HTMLDocument.getElementByName()

Availability

BlackBerry® Device Software version 4.6 or later

The getElementByName() method returns an array of the elements in the document with the specified name.

This method behaves differently depending on the document type:

  • If the document is an HTML document, this method returns all elements with the specified name. When searching HTML documents, this element is case-insensitive.

  • If the document is an XHTML document, this method only returns form control elements with the specified name. When searching XHTML documents, this method is case sensitive.

Syntax

HTMLDocument.getElementsByName( elementName )

Parameters

Parameter

Type

Description

elementName

String

The value of the name attribute of an element to match on.

Return values

Returns a new NodeList object containing an array of all the elements with the given name. If the document is an XHTML document, only form control elements (<button>, <input>, <select>, <textarea>) with the given name are returned.

Exceptions

None.

Method: HTMLDocument.open()

Availability

BlackBerry® Device Software version 3.8 or later

The open() method opens a document stream for writing.

Syntax

HTMLDocument.open()

Parameters

None.

Return values

None.

Exceptions

None.

Method: HTMLDocument.write()

Availability

BlackBerry® Device Software version 3.8 or later

The write() method writes a string of text to a document stream opened by HTMLDocument.open().

Syntax

HTMLDocument.write( text )

Parameters

Parameter

Type

Description

text

String

The text to be parsed.

Return values

None.

Exceptions

None.

Method: HTMLDocument.writeln()

Availability

BlackBerry® Device Software version 3.8 or later

The writeln() method writes a string of text, followed by a new line character to a document stream opened by HTMLDocument.open().

Syntax

HTMLDocument.writeln( text )

Parameters

Parameter

Type

Description

text

String

The text to be parsed.

Return values

None.

Exceptions

None.


Was this information helpful? Send us your comments.