Object name Property - Change the name of an <object> element: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Object

Description

Object name Property - Change the name of an <object> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

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

<script>
function myFunction() {/*from  w  w  w . j  av  a2s.co  m*/
    document.getElementById("myObject").name = "newObjName";
    document.getElementById("demo").innerHTML = "The name of the object was changed from 'obj1' to 'newObjName'";
}
</script>

</body>
</html>

Related Tutorials