Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>Click the button to create a VIDEO element with controls that will play a movie in a .mp3 or .ogg file format (depending on browser support).</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = document.createElement("VIDEO"); if (x.canPlayType("video/mp4")) { x.setAttribute("src","movie.mp4"); } else { x.setAttribute("src","movie.ogg"); } x.setAttribute("width", "320"); x.setAttribute("height", "240"); x.setAttribute("controls", "controls"); document.body.appendChild(x); } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_video_create by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:05:53 GMT --> </html>
Result:
Try it Yourself - © w3schools.com