这段代码在ie下显示正常,可以在firefox好像没什么作用,请高手赐教,谢谢! var debug = false ; 
function switchTab (tab) 
{ event.returnValue = false ; 
var tabName = getTabGroupName (tab.id) ; 
if (tabName == '') 
{ alert ("No tabName for tab [" + tab.id + "]") ; 
return ; 

var index = 1 ; 
while (true) 
{ var tabTitle = eval ("document.all ('" + tabName + '_' + index + "')") ; 
if (tabTitle == undefined) 
break ; 
deactiveTabTitle (tabTitle , tabName) ; 
var tabContent = eval ("document.all ('" + tabName + '_' + index + '_content' + "')") ; 
if (tabContent != undefined) 
tabContent.style.display = "NONE" ; 
index ++ ; 

if (debug) 
alert ("Find " + (index - 1) + " tab title(s) for TabName [" + tabName + "]") ; 
activeTabTitle (tab , tabName) ; 
var tabContent = eval ("document.all ('" + tab.id + '_content' + "')") ; 
if (tabContent != undefined) 
tabContent.style.display = "BLOCK" ; 
} function cancelTab () 


function getTabGroupName (tabId) 

if (tabId == '' ¦ ¦ tabId == undefined) 

alert ("tabId is NULL! [" + tabId + "]") ; 
return ; 

var i = tabId.lastIndexOf ('_') ; 
if (i <= 1) 
return '' ; 
return tabId.substr (0 , i) ; 

function deactiveTabTitle (tab , tabName) 

tab.className = tabName + "_off" ; 
} function activeTabTitle (tab , tabName) 

tab.className = tabName + "_on" ; 

解决方案 »

  1.   

    请问如何修改才能在firefox下使用?
      

  2.   

    修改成这样,不行,还有什么地方要改? var debug = false ;
    function switchTab (tab)
    { event.returnValue = false ;  
    var tabName = getTabGroupName (tab.id) ;
    if (tabName == '')
    { alert ("No tabName for tab [" + tab.id + "]") ;
    return ;
    }
    var index = 1 ;
    while (true)
    { var tabTitle = eval ("document.getElementById ('" + tabName + '_' + index + "')") ;
    if (tabTitle == undefined)
    break ;
    deactiveTabTitle (tabTitle , tabName) ;
    var tabContent = eval ("document.getElementById ('" + tabName + '_' + index + '_content' + "')") ;
    if (tabContent != undefined)
    tabContent.style.display = "NONE" ;
    index ++ ;
    }
    if (debug)
    alert ("Find " + (index - 1) + " tab title(s) for TabName [" + tabName + "]") ;
    activeTabTitle (tab , tabName) ;
    var tabContent = eval ("document.getElementById ('" + tab.id + '_content' + "')") ;
    if (tabContent != undefined)
    tabContent.style.display = "BLOCK" ;
    } function cancelTab ()
    {
    }
    function getTabGroupName (tabId)
    {
    if (tabId == '' || tabId == undefined)
    {
    alert ("tabId is NULL! [" + tabId + "]") ;
    return ;
    }
    var i = tabId.lastIndexOf ('_') ;
    if (i <= 1)
    return '' ;
    return tabId.substr (0 , i) ;
    }
    function deactiveTabTitle (tab , tabName)
    {
    tab.className = tabName + "_off" ;
    }

    function activeTabTitle (tab , tabName)
    {
    tab.className = tabName + "_on" ;
    }
      

  3.   

    没反应是因为你的JS在FF里出错了,IE与FF的JS区别可以参考这里
    http://blog.csdn.net/herowach/archive/2007/09/13/1783687.aspx
    在FF下调式可以用Firebug