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