功能点击一个按钮button ,取消 css 样式的函数,我想取消页面所有class  如果修改,请教高手支招!
html:<button type="button" id="textMode" onclick="textMode()">纯文本通道</button>js://纯文本通道执行函数----------------------
function textMode(keyContorl){
if(keyContorl == undefined){textModeState = textModeState;}
else if(keyContorl == true){if(textModeState){return false;};}
else{if(!textModeState){return false;};}
if(!textModeState){
for(var i=0;i<allLink.length;i++){allLink[i].setAttribute("href",textModeStyleURL);}
frameTextMode();
imgTextMode();
textModeState = true;
if($("textmodebutton")){$("textmodebutton").setAttribute("value","切换为可视模式");}
if($("textmodebutton")){$("textmodebutton").setAttribute("title","切换为可视模式");}
if($("textmodebutton")){$("textmodebutton").style.width = "130px";}
setCookie("textModeState",1);
guidesHeightRefresh();
clearStyle();
}
else{
window.location.reload();
setCookie("textModeState",0);
}
}
//页面样式清除函数------------------------
function clearStyle(){
var newAllElements = $("container").getElementsByTagName("*");
for(var b=0;b<newAllElements.length;b++){newAllElements[b].style.cssText = "";}
for(var c=0;c<newAllElements.length;c++){newAllElements[c].style.height = "auto";};
try{
$("rightcolumn").style.height = "";
$("mainrightcolumn").style.height = "";
}
catch(e){}
}

解决方案 »

  1.   

    我不是高手,打个酱油。
    function clearStyle(){
      var newAllElements = $("container").getElementsByTagName("*");
      for(var b=0;b<newAllElements.length;b++){newAllElements[b].className= "";}
      for(var c=0;c<newAllElements.length;c++){newAllElements[c].style.height = "auto";};
      try{
            $("rightcolumn").style.height = "";
           $("mainrightcolumn").style.height = "";
       }
       catch(e){}
    }
    className,不用style.cssText 
      

  2.   

    干嘛这么复杂呢先把你要显示的css样式设置到一个sheet用disabled开关来控制