CodeAPI

Document

A complete web page, which consists of a Header, Page, and Footer.
Select the current document using: $w("Document").

Table of Contents

PROPERTIES

?
Store values associated with an object.
backgroundGets an object containing information about the document's background, such as its image or video source.
childrenGets the document's Header, Page, and Footer.
typeGets the document's type.

OBJECTS

?
Objects used when setting, getting, or calling the properties and methods listed above.
BackgroundOptionsAn object used by the background property that contains the background options.

background

Gets an object containing information about the document's background, such as its image or video source.

Syntax

get background(): BackgroundOptions

Examples

Get the background information

let backgroundOpts = $w("#myElement").background;

let bgSrc = backgroundOpts.src;
// "wix:image://v1/68d3a9_1de7529c444b4c9eb38401f8efe0cad2.jpg/flowers.jpg#originWidth=1970&originHeight=1120"

Set the background image to be an image from the Media Manager

$w("#myElement").background.src = "wix:image://v1/68d3a9_1de7529c444b4c9eb38401f8efe0cad2.jpg/flowers.jpg#originWidth=1970&originHeight=1120";

Set the background image to be an image from the web

$w("#myElement").background.src = "http://placehold.it/250x250";

children

Gets the document's Header, Page, and Footer.

See Also

Header, Page, Footer

Syntax

get children(): Array<Node>
TYPE
?
The kind of data the property stores.
Array<Node>

Examples

Get the document's children

let docChildren = $w("Document").children;

let firstChildType = docChildren[0].type;   // "$w.Page"
let secondChildType = docChildren[1].type;  // "$w.Header"
let thirdChildType = docChildren[2].type;   // "$w.Footer"

type

Gets the document's type.

Description

Gets the string "$w.Document".

Syntax

get type(): string
TYPE
?
The kind of data the property stores.
string

Examples

Get the document's type

let docType = $w("Document").type;  // "$w.Document"

BackgroundOptions

An object used by the background property that contains the background options.

Description

Setting the src property of the BackgroundOptions object changes the displayed image or video to the image or video found at the new src value.

Getting the src property of the BackgroundOptions object returns the location of the current image or video file.

Images can either be from the Media Manager or an external image from any web location. Videos must come from the Media Manager.

The URL formats supported are:

  • Images from the Media Manager: wix:image://v1/<uri>/<filename>#originWidth=<width>&originHeight=<height>[&watermark=<watermark_manifest_string>]
  • Videos from the Media Manager: wix:video://v1/<video_uri>/<filename>#posterUri=<poster_uri>&posterWidth=<width>&posterHeight=<height>
  • Images from the web: http(s)://<image url>

See Also

background

Syntax

type BackgroundOptions = {
  src: string
}
MEMBERS
?
The kind of data the property stores.
src
string
The file location of the background image.

Examples

Get the background information

let backgroundOpts = $w("#myElement").background;

let bgSrc = backgroundOpts.src;
// "wix:image://v1/68d3a9_1de7529c444b4c9eb38401f8efe0cad2.jpg/flowers.jpg#originWidth=1970&originHeight=1120"

Set the background image to be an image from the Media Manager

$w("#myElement").background.src = "wix:image://v1/68d3a9_1de7529c444b4c9eb38401f8efe0cad2.jpg/flowers.jpg#originWidth=1970&originHeight=1120";

Set the background image to be an image from the web

$w("#myElement").background.src = "http://placehold.it/250x250";