Example
Change the width of an <object> element to 400px:
document.getElementById("myObject").width = "400";
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The width property sets or returns the value of the width attribute of an <object> element.
The width attribute specifies the width of an object.
Tip: Use the height property to set or return the value of the height attribute of an <object> element.
Browser Support
Property | |||||
---|---|---|---|---|---|
width | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the width property:
objObject.width
Set the width property:
objObject.width=pixels
Property Values
Value | Description |
---|---|
pixels | Specifies the width of the object, in pixels (e.g. height="100") |
Technical Details
Return Value: | A Number, representing the width of the object, in pixels |
---|
More Examples
Example
Get the width of an <object> element:
var x = document.getElementById("myObject").width;
The result of x will be:
250
Try it Yourself »
Example
Change the height and width of an <object> element to 300px:
document.getElementById("myObject").height = "500";
document.getElementById("myObject").width = "500";
Try it Yourself »
Related Pages
HTML reference: HTML <object> width attribute
< Object Object