Create an Object Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Object

Introduction

You can create an <object> 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 element with an embedded flash file</button>

<script>
function myFunction() {//from  www  .j  a va  2  s . c om
    var x = document.createElement("OBJECT");
    x.setAttribute("data", "helloworld.swf");
    x.setAttribute("width", "400");
    x.setAttribute("height", "400");
    document.body.appendChild(x);
}
</script>

</body>
</html>

Related Tutorials