功能点击一个按钮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){}
}
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){}
}
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 。