<!DOCTYPE html> <html> <head> <title>ABC</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript"> function sample() { var canvas = document.getElementById('cam'); if (canvas.getContext) { var context = canvas.getContext('2d'); context.fillRect(20,40,50,100); } } </script> </head> <body onLoad="sample()"> <h2>図形を描く</h2> <canvas id="cam"></canvas> </body> </html>