width property (document)
Retrieves the width of the browser window's client area.
It is not recommended to use this property.
- If you need the width of the client area, use the clientWidth property of the html element.
- To get the width of the document's contents, use the getBoundingClientRect method of the body element.
Syntax:
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?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments