Object name Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Object

Description

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

Set the name property with the following Values

Value Description
name Sets the name of the <object> element

Return Value

A String, representing the name of the <object> element

The following code shows how to get 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   ww  w.j a  va  2 s .c  om*/
    var v = document.getElementById("myObject").name ;
    document.getElementById("demo").innerHTML = v;
}
</script>

</body>
</html>

Related Tutorials