我有一個要求,我需要創建一個畫布,並在其內部繪製程序並將其放入一個選取框內,所有這些都通過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