Need help with drawImage() method in JavaScript
<head>
</head>
<body>
<script type = "text/javascript">
var body, canvas, img, cxt;
body = document.getElementsByTagName("body")[0];
canvas = document.createElement("canvas");
canvas.style.width = "1000px";
canvas.style.height = "500px";
body.appendChild(canvas);
img = document.createElement("img");
cxt = canvas.getContext("2d");
img.onload = function () {
cxt.drawImage(img,0,0,1000,500,0,0,1000,500);
}
img.src = "/clouds.png";
</script>
</body>