<!DOCTYPE html>
<html>
<body>
<p>Click the button to create an OBJECT and a PARAM element with an embedded audio file.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x = document.createElement("OBJECT");
x.setAttribute("data", "horse.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>