Create a Parameter Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Parameter

Introduction

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">create an OBJECT and a PARAM element with an embedded audio file</button>

<script>
function myFunction() {/*from   w  w w  . j  ava2  s  . co  m*/
    var x = document.createElement("OBJECT");
    x.setAttribute("data", "your.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>

Related Tutorials