Javascript Reference - HTML DOM Parameter Object








The Parameter object represents an HTML <param> element.

The <param> element defines parameters for plugins embedded with an <object> element.

Parameter Object Properties

Property Description
name Sets or gets the name attribute of a parameter
value Sets or gets the value attribute of a parameter

Standard Properties and Events

The Parameter object supports the standard properties and events.

Example

We can access a <param> element by using getElementById().


<!DOCTYPE html>
<html>
<body>
<object data="notExist.wav">
  <param id="myParam" name="autoplay" value="true">
</object><!--  w ww.  ja  va2 s . c  o  m-->
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
    var x = document.getElementById("myParam").name;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

We can create a <param> element by using the document.createElement() method.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!-- w  w w .java  2  s  . c om-->
    var x = document.createElement("OBJECT");
    x.setAttribute("data", "notExist.wav");
    x.setAttribute("id", "myObject");
    document.body.appendChild(x);

    var y = document.createElement("PARAM");
    y.setAttribute("name", "autoplay");
    y.setAttribute("value", "true");
    document.getElementById("myObject").appendChild(y);
}
</script>
</body>
</html>

The code above is rendered as follows: