在IE中,利用 eval(idName) 可以取得 id 为 idName 的 HTML 对象,在MF 中不能。
 解决方法
        用 getElementById(idName) 代替 eval(idName)。

解决方案 »

  1.   

    我用楼上的方法改成这样
    var targetImg =getElementById("followImg" + ino);
    var targetDiv =getElementById("follow" + ino);可还是没有效果
      

  2.   

    var targetImg =getElementById["followImg" + ino];
    var targetDiv =getElementById["follow" + ino];改成这样再试试
      

  3.   

    菜鸟哦,随便说说var targetImg =document.getElementById("followImg" + ino);
    var targetDiv =document.getElementById("follow" + ino);
      

  4.   

    按4楼的写法,另外,不知FF对targetImg.loaded是否支持判断。
      

  5.   

    非常感谢楼上几位打侠,效果终于出来了。
    还有个问题,在load.asp 到入的框架页里有一句这样的javascript 语句。同样在ie 下正常。到了ff就出不了效果了,不知道应该怎么修改,语句如下:
    <SCRIPT>
    parent.followImg<%=id%>.loaded="yes";
    parent.followTd<%=id%>.innerHTML='<table width=100% cellpadding=10 style=TABLE-LAYOUT:fixed><tr><td width=100% style=WORD-WRAP:break-word class=style13><%=content%></td></tr></table>';
    </SCRIPT>在论坛上找到这个方法可是不知道怎么下手
    innerHTML的区别 
    Firefox不支持innerHTML,   解决办法可以如下 
                  rng   =   document.createRange(); 
                  el   =   document.getElementById(elementid); 
                  rng.setStartBefore(el); 
                  htmlFrag   =   rng.createContextualFragment(content); 
                  while   (el.hasChildNodes())   //清除原有内容,加入新内容 
                                el.removeChild(el.lastChild); 
                  el.appendChild(htmlFrag);
      

  6.   

    Firefox 不支持innerHTML ?????谁给讲解一下
      

  7.   

    有哪位高人在浏览器上处理过innerHTML  的问题吗?
      

  8.   

    我这样改在firefox里还是实现不了载入load.asp页的效果,不知道哪位做过这方面请教一下
    <SCRIPT>
    parent.document.getElementById(followImg<%=id%>).loaded="yes";
    parent.document.getElementById(followTd<%=id%>).innerHTML='<table width=100% cellpadding=10 style=TABLE-LAYOUT:fixed><tr><td width=100% style=WORD-WRAP:break-word class=style13><%=content%></td></tr></table>';
    </SCRIPT>
      

  9.   

    <script>
    if(navigator.userAgent.toLowerCase().indexOf("firefox") != -1)//ff
    {
      parent.document.getElementById(followImg<%=id%>).loaded="yes";
      var el=parent.document.getElementById(followTd<%=id%>);
      rng  = document.createRange();   
      rng.setStartBefore(el);
      var content='<table width=100% cellpadding=10 style=TABLE-LAYOUT:fixed><tr><td width=100% style=WORD-WRAP:break-word class=style13><%=content%></td></tr></table>';   
      htmlFrag =rng.createContextualFragment(content);   
      while(el.hasChildNodes())       //清除原有内容,加入新内容   
           el.removeChild(el.lastChild);   
      el.appendChild(htmlFrag);
    }
    if(window.ActiveXObject)//IE
    {
      parent.document.getElementById(followImg<%=id%>).loaded="yes";
    parent.document.getElementById(followTd<%=id%>).innerHTML='<table width=100% cellpadding=10 style=TABLE-LAYOUT:fixed><tr><td width=100% style=WORD-WRAP:break-word class=style13><%=content%></td></tr></table>';
    }
      

  10.   

    ff好象老的版本不支持innerHTML,新版本支持innerHTML
    我用的2.0的就没问题,但是哪个版本以前的用不了就不太清楚了
      

  11.   

    我用了aaron81939097 的方法结果在ie 和  ff里还是实现不了效果啊。parent.document.getElementById(followImg <%=id%> ).loaded="yes"; 
    parent.document.getElementById(followTd <%=id%> ).innerHTML=' <table   width=100%   cellpadding=10   style=TABLE-LAYOUT:fixed> <tr> <td   width=100%   style=WORD-WRAP:break-word   class=style13> <%=content%> </td> </tr> </table> '; 
    这句我放在ie里试过得不出内容的
      

  12.   

    parent.document.getElementById("followImg"+"+<%=id%>+").loaded="yes";   
    parent.document.getElementById("followTd"+"+<%=id%>+").innerHTML='   <table       width=100%       cellpadding=10       style=TABLE-LAYOUT:fixed>   <tr>   <td       width=100%       style=WORD-WRAP:break-word       class=style13>   <%=content%>   </td>   </tr>   </table>   ';   
    这样再试
      

  13.   

    根据 aaron81939097 的思路 我改成这样
    parent.document.getElementById("followImg<%=id%>").loaded="yes";       
    parent.document.getElementById("followTd<%=id%>").innerHTML='<table width=100% cellpadding=10 style=TABLE-LAYOUT:fixed><tr><td width=100% style=WORD-WRAP:break-word class=style13><%=content%></td></tr></table>';  
    结果是在ie里 能够正常得出load.asp 的内容。但在ff里 还是得不出结果
    我在ff里是这样修改:
    if(navigator.userAgent.toLowerCase().indexOf("firefox")   !=   -1)//ff 

        parent.document.getElementById("followImg<%=id%>").loaded="yes"; 
        var   el=parent.document.getElementById("followTd<%=id%>"); 
        rng     =   document.createRange();       
        rng.setStartBefore(el); 
        var   content='<table width=100% cellpadding=10 style=TABLE-LAYOUT:fixed><tr><td width=100% style=WORD-WRAP:break-word class=style13><%=content%></td></tr></table>'; 
        htmlFrag   =rng.createContextualFragment(content);       
        while(el.hasChildNodes())               //清除原有内容,加入新内容       
                  el.removeChild(el.lastChild);       
        el.appendChild(htmlFrag); 

    if(window.ActiveXObject)//IE 

    parent.document.getElementById("followImg<%=id%>").loaded="yes";       
    parent.document.getElementById("followTd<%=id%>").innerHTML='<table width=100% cellpadding=10 style=TABLE-LAYOUT:fixed><tr><td width=100% style=WORD-WRAP:break-word class=style13><%=content%></td></tr></table>';  
    }假如以上代码在load.asp 页里没有错误,那么我调用load.asp的也是不是还有其他不对的地方?调用load.asp页的代码是这样:
    <table width="43%"><tr><td class=style13 width=41% >&nbsp;<img loaded=no src=images/plus.gif id=followImg5 style=cursor:hand; onclick=loadThreadFollow(5)>aaa <a href=Show.asp?id=5  target=_blank onClick=window.close()>bbb</a></td>
    <td align=middle width=37% class=style13>ccc</td>
    <td width=22% colspan="3" align=middle class=style13>ccc普通</td>
    </tr>
    <tr height=20 style="display:none" id=follow5><td id=followTd5 align=left class=a4 colspan=3> Loading...</td></tr>
    <tr height=1 ><td colspan=5 background=images/line.gif></td></tr></table>
    <script>
    function loadThreadFollow(ino,online){
    var targetImg =eval("followImg" + ino);
    var targetDiv =eval("follow" + ino);
    if (targetDiv.style.display!='block'){
    targetDiv.style.display="block";
    targetImg.src="images/minus.gif";
    if(targetImg.loaded=="no"){document.frames["hiddenframe"].location.replace("loading.asp?id="+ino+"&forumid="+online+"");}
    }else{
    targetDiv.style.display="none";
    targetImg.src="images/plus.gif";
    }
    }
    document.write("<iframe height=0 width=0 name=hiddenframe class=style13></iframe>")
    </script>6楼的nicholsky  提到FF对targetImg.loaded是否支持判断。难道这里还有出处吗?
      

  14.   

    IE下可以用document.frames("name").document的方式取得frame中所嵌页面的document对象,FF下却会得到null,解决的的办法是document.getElementById(framename).contentWindow.document,也可以使用
    window.frames[frameName].document 直接获取frame里的document对象
      

  15.   

    用window.frames['hiddenframe'].location.replace看看
      

  16.   

    我用window.frames['hiddenframe'].location.replace 这个方法在ie  里可行,但在ff里还是不能得出结果。改成这个document.getElementsByName("hiddenframe").contentWindow.location.replace  结果在ie 和ff 多不能显示load.asp的内容
      

  17.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>
    <body>
    <input name="" type="button" value="click" onclick='loadThreadFollow(5)'/>
    <table>
    <tr style="display:none" id='follow5'>
    <td id='followTd5'>123</td>
    </tr>
    </table>
    <script>
    function loadThreadFollow(i){
    var targetDiv =document.getElementById("follow" + i);
    if (targetDiv.style.display==''){
    targetDiv.style.display="none";
    }else{
    targetDiv.style.display="";
    window.frames["hiddenframe"].location.replace("loading.asp?id="+i);
    }
    }
    document.write("<iframe height='0' width='0' name='hiddenframe'></iframe>")
    </script></body>
    </html>
    loading.asp<script>      
    parent.document.getElementById("followTd<%=request.QueryString("id")%>").innerHTML='321';  
    </script>
    我用ff ie7测试貌似没问题
    你先用这个测试看看
      

  18.   

    还是不行就用其他方法吧
    例如
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>
    <body>
    <input name="" type="button" value="click" onclick='loadThreadFollow(5)'/>
    <table>
    <tr style="display:none" id='follow5'>
    <td id='followTd5'>123</td>
    </tr>
    </table><script>
    function loadThreadFollow(i){
    var targetDiv =document.getElementById("follow" + i);
    if (targetDiv.style.display==''){
    targetDiv.style.display="none";
    }else{
    targetDiv.style.display="";
    document.getElementById("a").src = "loading.asp?id="+i+"&"+Math.random();
    }
    }
    </script>
    <script id="a"></script>
    </body>
    </html>loading.aspdocument.getElementById("followTd5").innerHTML='321';
      

  19.   

    loading.asp document.getElementById("followTd<%=request.QueryString("id")%>").innerHTML='321';
      

  20.   

    终于好了,太感谢cloudgamer 了。 非常感谢。