You are here: Reference > JavaScript > client-side > HTML DOM > properties > width (document)

width property (document)

Browser support:
Retrieves the width of the browser window's client area.
It is not recommended to use this property.

Syntax:

object.width;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Integer that sets or retrieves the width of the document, in pixels.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the width property:
<head>
    <script type="text/javascript">
        function GetDocSizes () {
            alert ("width x height: " + document.width + " x " + document.height);
        }
    </script>
</head>
<body>
    <button onclick="GetDocSizes ();">Get document dimensions!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content