[求助]javascript属性设置事件无效
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Cartoon</title>
<script>
var flag=1;
var dx=1,dy=1;
var x=0,y=50;
var v;
function moveRight(){
var r=document.getElementById("cartoon");
x+=dx;
r.style.left=x+"px";
}
function moveLeft(){
var l=document.getElementById("cartoon");
x-=dx;
l.style.left=x+"px";
}
function moveUp(){
var u=document.getElementById("cartoon");
y-=dy;
u.style.top=y+"px";
}
function moveDown(){
var d=document.getElementById("cartoon");
y+=dy;
d.style.top=y+"px";
}
function moveCartoon(){
var o=document.getElementById("cartoon");
var xx=x;
var yy=y;
if(xx==0&&yy==50) flag=1;
if(xx==300&&yy==50) flag=2;
if(xx==300&&yy==200) flag=3;
if(xx==0&&yy==200) flag=4;
switch(flag){
case 1:moveRight();break;
case 2:moveDown();break;
case 3:moveLeft();break;
case 4:moveUp();break;
}
v=setTimeout("moveCartoon()",10);
}
function stopCartoon(){
clearTimeout(v);
}
function look(){
if(event.shiftKey)
alert("Shift Forbidden!");
if(event.ctrlKey)
alert("Ctrl Forbidden!");
if(event.altKey)
alert("Alt Forbidden!");
}
document.onkeydown=look;
document.b1.onclick=moveCartoon;
</script>
</head>
<body>
<input type="button" value="Start" name="b1">
<input type="button" value="Stop" onclick="stopCartoon()"><br>
<div id="cartoon" style="position:absolute;">
Cartoon!!!
</div>
</body>
</html>
红色的那句话为什么不起作用?