点击按纽后 切换了图片 如果点不同的图片 如何跳转到不同的地址??? 
看看代码哪有问题?谢谢了 
<img style="z-index:0" width="360px" height="230px" id=obj src ="../Images/netImages/dashiguan1.jpg" onclick="jumpPhoto()" /> <script> 
function jumpPhoto() 
{  
var obj=document.getElementById("obj"); 
    if(obj.src="../Images/netImages/dashiguan1.jpg") 
    { 
        window.location= "../Images/netImages/dashiguan1.jpg"; 
    } 
      else  if(obj.src="../Images/netImages/anye1.jpg") 
    { 
        window.location= "../Images/netImages/anye1.jpg"; 
    } 
    
    
} </script> 
 
 alert()了一下 路径都对 都是当前图片的路径 可是跳过去 还是显示第一张图。。

解决方案 »

  1.   

    if(obj.src=="../Images/netImages/dashiguan1.jpg") 
        { 
            window.location= "../Images/netImages/dashiguan1.jpg"; 
        } 
          else  if(obj.src=="../Images/netImages/anye1.jpg") 
        { 
            window.location= "../Images/netImages/anye1.jpg"; 
        } 
      

  2.   

    因为obj.src="../Images/netImages/dashiguan1.jpg"是一个赋值操作,不是一个判断,window.location= "../Images/netImages/dashiguan1.jpg"; 这句永远都会被执行,没听过js里面判断是用单=的
      

  3.   

    你就不用加图片,直接上面alert(1),下面alert(2),你看下是不是不管你图片路径怎么变,永远都alert(1)就行了
      

  4.   

    嗯 最后成alert(2)了...这该怎么办..也不能断点..
      

  5.   

    我改了路径就行了 
    if(obj.src=="http://localhost:7182/WebUI/Images/netImages/dashiguan1.jpg")
        {
            window.location= "../Images/netImages/dashiguan1.jpg";
            
        }
          else if(obj.src=="http://localhost:7182/WebUI/Images/netImages/anye1.jpg")
        {
            window.location= "../Images/netImages/anye1.jpg"; 
        }
    可是端口会变的啊...
      

  6.   

    你只判断文件名就行了,不用加路径    var src = obj.src.substring(obj.src.lastIndexOf("/")+1);
        if(src=="dashiguan1.jpg") 
        { 
            window.location= "../Images/netImages/dashiguan1.jpg"; 
            
        }else if(src=="anye1.jpg"){ 
            window.location= "../Images/netImages/anye1.jpg"; 
        }