我是用treeview做的菜单,要求点击父菜单,图片要转换,调用了js,不知道为何ie6.0的浏览。点击前的图片是可以显示的,点击后的图片显示不出来,对那个图片右击图片显示,图片才出来?但是很奇怪,ie7.0以上的却可以将图片正常显示。。未点击前的图片为_yi,点击后的图片为_er,下面是调用的js文件:
 function GoClick()
 {
   var obj = event.srcElement;
   var tb=obj;
   if (tb.tagName.toUpperCase()=="IMG")
   {
       if(tb.parentElement.tagName.toUpperCase()=="A")
       {
           tb=tb.parentElement;
       }
   }
   tb=tb.parentElement.parentElement.parentElement.parentElement;
   try
   {
       if (tb.nextSibling.tagName.toUpperCase()=="DIV")
       {
           var td;
           
           if (obj.tagName.toUpperCase()=="A")
           {
                td=obj.parentElement;
           }
           else if(obj.tagName.toUpperCase()=="IMG")
           {
                td=obj.parentElement.parentElement.nextSibling;
           }
           
           if (td.className.indexOf("level_click_1") >= 0)
           {
                td.className=td.className.replace("level_click_1","level1 ");
           }
           else
           {
                td.className=td.className.replace("level1","level_click_1");
           }
           if (td.previousSibling.firstChild.firstChild.src.indexOf("_yi")>0)
           {
                td.previousSibling.firstChild.firstChild.src=td.previousSibling.firstChild.firstChild.src.replace("_yi","_er");
           }
           else
           {
                td.previousSibling.firstChild.firstChild.src=td.previousSibling.firstChild.firstChild.src.replace("_er","_yi");
           }
           
           
           if (td.className.indexOf("level2_click") >= 0)
           {
                td.className=td.className.replace("level2_click","level2 ");
           }
           else
           {
                td.className=td.className.replace("level2","level2_click");
           }
       }
   }
   catch(e){}
 }
请各位大侠们,帮忙看看给点意见,如何解决?

解决方案 »

  1.   

    src后的的图片地址加个随机参数看看?
    .previousSibling.firstChild.firstChild.src=td.previousSibling.firstChild.firstChild.src.replace("_yi","_er")+"?a="+Math.Random().toString()
      

  2.   

    cpp2017:我刚试过了,加了随机参数,点击后显示的还是未点击前的图片,就是说图片未发生转换,请问还有其他办法吗?
      

  3.   

    你做的好像没问题吧   直接装IE8   这样预览应该没问题了  是浏览器的毛病   尤其是IE6问题最多