Object width Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Object

Description

The width property sets or gets the width attribute of an <object> element.

Set the width property with the following Values

Value Description
pixels Sets the width of the object, in pixels (e.g. height="100")

Return Value

A Number, representing the width of the object, in pixels

The following code shows how to change the width of an <object> element to 400px:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<object id="myObject" width="250" height="200" data="helloworld.swf"></object>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//w  w  w  . j  av a2  s  . com
    document.getElementById("myObject").width = 200;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials