有没有办法将此JavaScript添加到HTML文件?

时间:2014-09-18 21:40:52

标签: javascript html

我可以将这样的JavaScript代码添加到HTML文件中吗?怎么样?

fill(0, 0, 0);
ellipse(200, 200, 375, 375);
fill(60, 0, 255);
triangle(200, 104, 280, 280, 120, 280);
fill(255, 255, 255);
var answer = floor(random(1, 5));
if (answer === 2) {
    text("NOT YET", 176, 200);
}
else if( answer===3)
{
    text("IMPLEMENTED", 159, 229);   
}
else if(answer===4){
    text("Yes",185,229);
}
else if(answer===1){
    text("NO",185,229);
}
else if(answer===5){
    text("Try Again",185,200);
}

1 个答案:

答案 0 :(得分:4)

<script type="text/javascript">
// code in here
</script>

你甚至不再需要'type'属性了!