Share via


BODY XHTML Element

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

The BODY element denotes the beginning and end of the document body. This is a block element and requires a closing tag. This is also the scripting object document.

Using this Element

There are some common properties and collections that apply to all the elements of the document object model, see Common Properties, Methods and Collections for the HTML Elements in Internet Explorer Mobile.

This element can be used within a web page with attributes.

This element can be used within scripts where it will have properties, events, methods and collections.

Attributes

The following table shows items that Internet Explorer Mobile supports.

Attribute Value Description

ALINK

Special

This attribute indicates the color that a hyperlink assumes when it is activated or clicked on. Note: Link colors are disabled on grayscale devices resulting in link colors always being black.

This attribute is equivalent to the CSS:

a:active { color: {color} };

BACKGROUND

URL

Specifies the URL of a background image to be tiled behind the images and text on a page.

Note: To improve readability, background images are disabled on grayscale devices and will not render.

This attribute is equivalent to the CSS:

background-image: url( {url} );

BGCOLOR

Special

Specifies the background color of the page. Values are specified in the format #RRGGBB where RR, GG and BB are hexadecimal values for red, green, and blue levels or can be specified by using one of the following color names listed below.

This attribute is equivalent to the CSS:

background-color: {color};
> [!NOTE] > Background colors on the body are disabled on grayscale devices. The page will always have a white background.

Color names:

  • aliceblue
  • antiquewhite
  • aqua
  • aquamarine
  • azure
  • beige
  • bisque
  • black
  • blanchedalmond
  • blue
  • blueviolet
  • brown
  • burlywood
  • cadetblue
  • chartreuse
  • chocolate
  • coral
  • cornflowerblue
  • cornsilk
  • crimson
  • cyan
  • darkblue
  • darkcyan
  • darkgoldenrod
  • darkgray
  • darkgreen
  • darkkhaki
  • darkmagenta
  • darkolivegreen
  • darkorange
  • darkorchidg
  • darkred
  • darksalmon
  • darkseagreen
  • darkslateblue
  • darkslategray
  • darkturquoise
  • darkviolet
  • deeppink
  • deepskyblue
  • dimgray
  • dodgerblue
  • firebrick
  • floralwhite
  • forestgreen
  • fuchsia
  • gainsboro
  • ghostwhite
  • gold
  • goldenrod
  • gray
  • green
  • greenyellow
  • honeydew
  • hotpink
  • indianred
  • indigo
  • ivory
  • khaki
  • lavender
  • lavenderblush
  • lawngreen
  • lemonchiffon
  • lightblue
  • lightcoral
  • lightcyan
  • lightgoldenrod-yellow
  • lightgreen
  • lightgrey
  • lightpink
  • lightsalmon
  • lightseagreen
  • lightskyblue
  • lightslategray
  • lightsteelblue
  • lightyellow
  • lime
  • limegreen
  • linen
  • magenta
  • maroon
  • medium-aquamarine
  • mediumblue
  • mediumorchid
  • mediumpurple
  • mediumseagreen
  • mediumslateblue
  • medium-springgreen
  • mediumturquoise
  • mediumvioletred
  • midnightblue
  • mintcream
  • mistyrose
  • moccasin
  • navajowhite
  • navy
  • oldlace
  • olive
  • olivedrab
  • orange
  • orangered
  • orchid
  • palegoldenrod
  • palegreen
  • paleturquoise
  • palevioletred
  • papayawhip
  • peachpuff
  • peru
  • pink
  • plum
  • powderblue
  • purple
  • red
  • rosybrown
  • royalblue
  • saddlebrown
  • salmon
  • sandybrown
  • seagreen
  • seashell
  • sienna
  • silver
  • skyblue
  • slateblue
  • slategray
  • snow
  • springgreen
  • steelblue
  • tan
  • teal
  • thistle
  • tomato
  • turquoise
  • violet
  • wheat
  • white
  • whitesmoke
  • yellow
  • yellowgreen

CLASS

 

 

ID

 

 

LEFTMARGIN

0…#

Specifies the left margin of the body in pixels. Negative values are allowed. The default value is 6.

This attribute is equivalent to the CSS:

margin-left: {n};

LINK

Special

Specifies the color for links on a page.

See BODY BGCOLOR for the format and possible color names.Note: Link colors are disabled on grayscale devices resulting in link colors always being black.

This attribute is equivalent to the CSS:

a { color: {color} };

ONLOAD

 

 

ONULOAD

 

 

RIGHTMARGIN

0…#

Specifies the right margin of the body in pixels. Negative values are not supported. The default value is 6.

This attribute is equivalent to the CSS:

margin-right: {n};

TEXT

Special

Specifies the color of the text on a page.

See BGCOLOR for the format and possible color names.

Text colors are disabled on grayscale devices resulting in text always being black.

This attribute is equivalent to the CSS:

color: {color};

STYLE

 

 

TOPMARGIN

0…#

Specifies the top margin of the body in pixels. Negative values are not supported. The default value is 6.

This attribute is equivalent to the CSS:

margin-top: {n}; margin-bottom: {n};

VLINK

Special

This attribute indicates the default color of hyperlinks that have already been activated.

Link colors are disabled on grayscale devices resulting in link colors always being black.

This attribute is equivalent to the CSS:

a:visited { color: {color} };

Scripting Properties

Property Type Access Comments

alinkColor

variant

Read/Write

Sets or retrieves the active link color in the specified document.

bgColor

variant

Read/Write

Sets or retrieves the background color of the specified document.

See BGCOLOR property for the format and possible color names.

> [!NOTE] > The color values returned by the browser are not prefixed with a ‘#’.

body

object

Read/Write

Sets or retrieves the body or frameset object that is the node of the current document object.

cookie

string

Read/Write

Sets or retrieves the string value of a cookie. sCookie is the string that specifies or receives the name=value pairs, plus any of the following values:

expires=date;

  • Setting no expiration date on a cookie causes it to expire when the browser closes. If you set an expiration date in the future, the cookie is saved across browser sessions. If you set an expiration date in the past, the cookie is deleted. Use GMT format to specify the date.

domain=domainname;

  • Setting the domain of the cookie allows pages on a domain made up of more than one server to share cookie information.

path=path;

  • Setting a path for the cookie allows the current document to share cookie information with other pages within the same domain—that is, if the path is set to /thispathname, all pages in /thispathname and all pages in subfolders of /thispathname can access the same cookie information.

secure;

  • Setting a cookie as secure; means the stored cookie information can be accessed only from a secure environment.

documentElement

Object

Read

Retrieves a reference to the root node of the document.

domain

string

Read/Write

Sets or retrieves the domain the document is on, which is initially set to the host that the document is on (like www.southridgevideo.com).

fgColor

variant

Read/Write

Sets or retrieves the foreground (text) color of the document.

See BGCOLOR property for the format and possible color names.

lastModified

string

Read

Contains the time and date the document was last modified

linkColor

variant

Read/Write

Sets or retrieves the color of the links in the document.

See BGCOLOR property for the format and possible color names.

location

string

Read/Write

Sets or retrieves the current URL of the document. It is also an object that represents information about the current document. See location object for more details.

parentWindow

object

Read

 

referrer

string

Read

Contains the URL of the document where the current document was linked from.

> [!NOTE] > This property will always return an empty string.

title

string

Read/Write

Contains the TITLE of the document.

URL

string

Read

Contains the URL of the current document.

vlinkColor

variant

Read/Write

Sets or retrieves the color of visited links in the specified document.

See BGCOLOR property for the format and possible color names.

Scripting Events

The following table shows items that Internet Explorer Mobile supports.

Event Comment

onload

This event fires right after the page is loaded

onunload

This event fires right before the current page is unloaded (for example, if the user navigates away from the page or refreshes the page)

Scripting Methods

The following table shows items that Internet Explorer Mobile supports.

Method Arguments Comments

clear

 

Syntax:

document.clear()

  • Does the same thing as document.open(). See open method below for more details.

close

 

Syntax:

document.close()

  • Closes output stream and forces the data written to the document to be displayed.

createElement

String

Syntax:

document.createElement(element)

  • Creates an instance of the element for the specified tag displayed.
  • element is a required String containing the name of the new element.

getElementById

 

Syntax:

Element=document.getElementById(id)

  • Returns the first object that matches the specified id. If no element id is given then a NULL is returned.
    id is a String containing the unique id of the element.

getElementsByTagName

 

Syntax:

Elements=document.getElementByTagName(tagName)

  • Returns a collection of objects based on the specified element name. If no element id is given then a NULL is returned.
    tagName is a String containing the name of the element.

open

([optional] string MIME-Type, [optional] variant replace)

Syntax:

document.open(MIMEtype,replace)

  • Opens a stream to a new document so that subsequent calls to document.write can append data to the document.
    MIMEtype is an optional String argument that specifies the type of data to write and display in the document.
    replace is an optional Variant argument that indicates whether calls to document.write replace existing content in the document.
> [!NOTE] > Supported only for devices running Smartphone 2002 and Pocket PC 2002 software or later.

write

array

Syntax:

document.write(sText)

  • Writes sText (which can contain HTML) to the specified document.

writeln

array

Syntax:

document.writeln(sText)

  • Writes sText (which can contain HTML) followed by a carriage return to the specified document. Carriage returns are ignored in HTML unless they are within preformatted text.

Scripting Collections

The following table shows items that Internet Explorer Mobile supports.

Collections Arguments Support Comments

all

 

Yes

 

   length

long

Read

 

   item

([optional] variant name, [optional] variant index)

Yes

 

anchors

 

Yes

This collection contains an array of anchor objects in the document.

   length

long

Read

 

   item

([optional] variant name, [optional] variant index)

Yes

 

   length

 

Yes

Always returns 0

forms

object

Yes

Collection of all FORM objects in the document in source order.

syntax:

[colForms=]document.forms

[oObject=]document.forms(vIndex)

colElements

  • Collection of forms
  • oObject
  • Reference to an individual item in the array of elements contained by the object.
  • vIndex
  • Required. Integer that specifies the element or collection to retrieve.Note: the value of vIndex cannot be accesed as a string.

   length

long

Read

Contains the number of form objects in the collection.

To find the number of elements in a particular form object, use: forms[index].elements.length, not forms[index].length.

   item

([optional] variant name, [optional] variant index)

Yes

 

frames

object

Yes

 

   length

long

Read

Always returns 0 on Windows Mobile Standard

   item

([optional] variant name, [optional] variant index)

Yes

 

images

object

Yes

 

   length

long

Read

 

   item

([optional] variant name, [optional] variant index)

Yes

 

links

object

Yes

Retrieves a collection all of the <A> (link) objects which have a HREF and all AREA objects in the document.

   length

long

Yes

Contains the number of elements in the links collection.

   item

([optional] variant name, [optional] variant index)

Yes

 

Requirements

Windows Mobile Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later

See Also

Concepts

Internet Explorer Mobile HTML Elements