thisLink,thisImage 是形式参数,在函数体内是局部变量。
调用的时候传给他的参数名是实际参数。
这两个名字你写成一样也是可以的,不影响使用。但是为了不引起用户混淆,增强可读性,通常是不写成一样。

解决方案 »

  1.   

    thisLink.outImage = new Image();
    thisLink.outImage.src = thisImage.src; thisLink.overImage = new Image();
    thisLink.overImage.src = "images/" + thisLink.id + "_on.gif";
    这段代码有什么用
      

  2.   

    function setupRollover(thisLink,thisImage){
    thisLink.imgToChange=thisImage;
    thisLink.onmouseout=function(){
    this.imgToChange.src=this.outImage.src;
    }
    thisLink.onmouseover=function(){
    this.imgToChange.src=this.overImage.src;
    }

    thisLink.outImage=new Image();
    this.outImage.src=thisImage.src;

    thisLink.overImage=new Image();
    this.overImage.src="images/"+thisLink.id+"_on.jpg";
    }
    为什么我这个总是运行不对啊   TypeError: linkObj is undefined    能指教一下吗    万分感谢
      

  3.   

    window.onload=rolloverInit;
    function rolloverInit(){
    for(var i=0;i=document.links.length;i++){
    var linkObj=document.links[i];
     if(linkObj.id){
    var imgObj=document.getElementById(linkObj.id+"Img");
     if(imgObj){
    setupRollover(linkObj,imgObj);
    }
    }
    }
    }
    function setupRollover(thisLink,thisImage){
    thisLink.imgToChange=thisImage;
    thisLink.onmouseout=function(){
    this.imgToChange.src=this.outImage.src;
    }
    thisLink.onmouseover=function(){
    this.imgToChange.src=this.overImage.src;
    }

    thisLink.outImage=new Image();
    this.outImage.src=thisImage.src;

    thisLink.overImage=new Image();
    this.overImage.src="images/"+thisLink.id+"_on.jpg";
    }为什么我这个总是运行不对啊   TypeError: linkObj is undefined    能指教一下吗    万分感谢
      

  4.   

    for(var i=0;i=document.links.length;i++){   ===============================> for(var i=0;i<document.links.length;i++){