<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>test</title>
<script type="text/javascript" src="js/canval.js">
window.onload=function{
var dom=document.getElementById("clock");
var ctx=dom.getContext("2d");
beginPath();
ctx.moveTo(200,200);
ctx.lineTo(500,500);
ctx.lineTo(200,500);
ctx.lineWidth=10;
ctx.stroke.style="yellow"
ctx.stroke();
}
</script>
<style type="text/css">
#clock{
border:1px solid red;
width:800px;
height: 800px;
margin: 100px auto;
margin-left:100px;
}
</style>
</head>
<body>
<canvas id="clock"></canvas>
</body>
</html>
怎么不能显示呢
js那不用写src了,因为你这个脚本本身就是内嵌在网页中,不是链接的外部文件。