event.srcElement.style.width = parseInt(200)+parseInt(x);

解决方案 »

  1.   

    event.srcElement是触发事件的元素,第一次bigger()元素是IMG,第二次就不是了,所以出错给img加个id="img1"
    把bigger()中的event.srcElement.style.width = 200+x;改成document.getElementById('img1').style.width = 200+x;
      

  2.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="javascript">
    var x=0,y=0;
    function change(){
    if(event.srcElement.tagName=="IMG"){
    bigger();
    }
    }
    function bigger(){
    if(x<100){
    x++;
    y++;
    //alert(x);//这里加了这句就是一点点变了...
    document.getElementById('img1').style.width = 200+x;
    setTimeout("bigger()",1000);
    }
    }
    </script>
    </head><body>
    <img id='img1' src="logo-shouye.gif" width="200" height="89" onMouseOver="change();">
    </body>
    </html>
      

  3.   

    可以传个ID或者重写setTimeout
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="javascript">var x=0,y=0;
    function change(str){
    if(event.srcElement.tagName=="IMG"){
    bigger(str);
    }
    }
    function bigger(str){
    var obj=document.getElementById(str)
    if(x<100){
    x++;
    y++;
    obj.style.width = parseInt(200)+parseInt(x);
    setTimeout("bigger('"+str+"')",10);
    }
    }
    </script>
    </head><body>
    <img src="http://community.csdn.net/logo/images/prj.210.67.gif" width="200" height="89" name="aa" onMouseOver="change(this.name);">
    </body>
    </html>