为什么这段代码不起作用?
<!DOCTYPE html>
<html lang="es">
<head>
<title>Euroqpa</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="type=text/javascript">
<!--
function drawcanvas() {
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="#FF0000";
ctx.fillRect(0,0,150,75);
}
//-->
</script>
</head>
<body>
<canvas id="myCanvas" width="300" height="300"></canvas>
<script type="text/javascript">
<!--
drawcanvas();
//-->
</script>
</body>
</html>
我认为head中定义的函数应该被body中的脚本识别。不是吗?
它说: Uncaught ReferenceError: drawcanvas is not defined