我有一个要求,我需要创建一个画布,并在其内部绘制程序并将其放入一个选取框内,所有这些都通过javascript。可能吗 ?请多指点html5画布滚动
作为后续:我写了以下内容,它创建画布,但不滚动它,但硬编码字幕的作品!
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
</head>
<body>
<marquee>you are welcome</marquee>
<input type="button" value="click" name="btn" onClick="btnClicked();"/>
<script>
function btnClicked()
{
alert('here');
var canvas = document.createElement('canvas');
context = canvas.getContext('2d');
// Draw whatever on your canvas
context.beginPath();
context.moveTo(70, 140);
context.lineTo(140, 70);
context.stroke();
var div = document.createElement('div');
div.appendChild(canvas);
var marquee = document.createElement('marquee');
marquee.appendChild(div);
document.body.appendChild(marquee);
}
</script>
</body>
</html>
它只有当你换了所有在'blink'元素的作用。 – alex 2011-03-21 13:48:11