ID/NAME 所引用的元素位于全局范围。请使用 W3C 的标准形式 document.getElementById() 。
[Break on this error] undefinedfbtn.length这个没取到!

解决方案 »

  1.   

    for(var i=0;i <fbtn.length;i++){ 这个写法的红色部分不兼容这个只是在IE内核的浏览器里才有效应该使用document.getElementById('fbtn')length
      

  2.   

    不过ID确实唯一的,所以不能形成数组形式
    建议加一个name="fbtn"使用document.getElementsByName("fbtn").length
      

  3.   

    我的js是刚接触,能说具体一点吗,怎么加一个name="fbtn",能不能把代码粘到你的机子上试试,给我调一下,谢谢了!
      

  4.   

    <div id=fbtn name="fbtn"> 
    <div id=fbtn_mask> </div> 
    <div id=fbtn_txt> 
    <div>公告讯息 </div> 
    <div >公告讯息 </div> 
    </div> 
    </div> 
    <div id=fbtnname="fbtn">  
    <div id=fbtn_mask> </div> 
    <div id=fbtn_txt> 
    <div>应用系统 </div> 
    <div>应用系统 </div> 
    </div> 
    </div> 
      

  5.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>css菜单</title>
    <style>
    body{
    background-color:#B8B8A0;
    }
    #fbtn{
    display:none;
    overflow:hidden;
    border-style:solid;
    border-width:1px;
    border-color:#e1e1c9 #e1e1c9 #6e6e56 #6e6e56;
    padding:1 1 1 1;
    width:115px;
    height:30px;
    }
    #fbtn_txt{
    position:relative;
    }
    #fbtn_txt div{
    height:30px;
    padding-top:11px;
    font-size:15px;
    color:#800080;
    text-align:center;
    cursor:hand;
    }
    #fbtn_mask{
    background-color:#ffffff;
    position:relative;
    width:100%;
    height:100%;
    }
    </style>
    </head>
    <body>
    <div id=fbtn name="fbtn">
    <div id=fbtn_mask></div>
    <div id=fbtn_txt>
    <div>公告讯息</div>
    <div >公告讯息</div>
    </div>
    </div>
    <div id=fbtn name="fbtn">  
    <div id=fbtn_mask></div>
    <div id=fbtn_txt>
    <div>应用系统</div>
    <div>应用系统</div>
    </div>
    </div>
    <script>
    var current=null;
    var t=null;
    for(var i=0;i<document.getElementsByName("fbtn").length ;i++){
    fbtn_txt[i].style.posTop=-30;
    fbtn_mask[i].style.posTop=-30;
    fbtn[i].index=i;
    fbtn[i].style.display="block";
    fbtn[i].onmouseover=function(){
    if(!current){
    current=this;
    domove(this.index);
    }
    else 
    if(current!=this){
    domove(current.index);
    domove(this.index);
    current=this;
    }
    }
    fbtn[i].onmouseout=function(){
    if(event.toElement==this.parentElement&t==this){
    domove(this.index);
    current=null;
    }
    }
    }
    function domove(num){
    var o=fbtn_txt[num];
    var m=fbtn_mask[num];
    if(o.style.posTop<-60){
    o.style.display="none";
    var t=o.children[1].innerHTML;
    o.children[1].innerHTML=o.children[0].innerHTML;
    o.children[0].innerHTML=t;
    o.style.posTop=-30;
    o.style.display="block";
    if(m.style.posTop>30)
    m.style.posTop=-30;
    else
    m.style.posTop=0;
    }
    else{
    m.style.posTop+=3;
    o.style.posTop-=3;
    setTimeout('domove('+num+')',15);
    }
    }
    </script>
    </body>
    </html>
    是不是这样啊,在IE上能显示,可是在firefox上就是什么都没有啊,再帮我看看啊 谢谢
      

  6.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>css菜单</title>
    <style>
    body{
    background-color:#B8B8A0;
    }
    #fbtn{
    display:none;
    overflow:hidden;
    border-style:solid;
    border-width:1px;
    border-color:#e1e1c9 #e1e1c9 #6e6e56 #6e6e56;
    padding:1 1 1 1;
    width:115px;
    height:30px;
    }
    #fbtn_txt{
    position:relative;
    }
    #fbtn_txt div{
    height:30px;
    padding-top:11px;
    font-size:15px;
    color:#800080;
    text-align:center;
    cursor:hand;
    }
    #fbtn_mask{
    background-color:#ffffff;
    position:relative;
    width:100%;
    height:100%;
    }
    </style>
    </head>
    <body>
    <div id=fbtn name="fbtn">
    <div id=fbtn_mask name="fbtn_mask"></div>
    <div id=fbtn_txt name="fbtn_txt">
    <div>公告讯息</div>
    <div>公告讯息</div>
    </div>
    </div>
    <div id=fbtn name="fbtn">  
    <div id=fbtn_mask name="fbtn_mask"></div>
    <div id=fbtn_txt name="fbtn_txt">
    <div>应用系统</div>
    <div>应用系统</div>
    </div>
    </div>
    <script>
    var current=null;
    var t=null;
    for(var i=0;i<document.getElementsByName("fbtn").length ;i++){
    document.getElementsByName("fbtn_txt")[i].style.posTop=-30;
    document.getElementsByName("fbtn_mask")[i].style.posTop=-30;
    document.getElementsByName("fbtn")[i].index=i;
    document.getElementsByName("fbtn")[i].style.display="block";
    document.getElementsByName("fbtn")[i].onmouseover=function(){
    if(!current){
    current=this;
    domove(this.index);
    }
    else 
    if(current!=this){
    domove(current.index);
    domove(this.index);
    current=this;
    }
    }
    document.getElementsByName("fbtn").onmouseout=function(){
    if(event.toElement==this.parentElement&t==this){
    domove(this.index);
    current=null;
    }
    }
    }
    function domove(num){
    var o=document.getElementsByName("fbtn_txt")[num];
    var m=document.getElementsByName("fbtn_mask")[num];
    if(o.style.posTop<-60){
    o.style.display="none";
    var t=o.children[1].innerHTML;
    o.children[1].innerHTML=o.children[0].innerHTML;
    o.children[0].innerHTML=t;
    o.style.posTop=-30;
    o.style.display="block";
    if(m.style.posTop>30)
    m.style.posTop=-30;
    else
    m.style.posTop=0;
    }
    else{
    m.style.posTop+=3;
    o.style.posTop-=3;
    setTimeout('domove('+num+')',15);
    }
    }
    </script>
    </body>
    </html>
      

  7.   

    firefox上的event和IE上的不同
    相关你再找一下这方面的资料吧