为什么这段代码无效
window.onload=function(){
var oTiwen=document.getElementById('tiwen');
var oFl=document.getElementById('fl');
var oFr=document.getElementById('fr');
oTiwen.onclick=function(){
// alert(getStyle(oFl,'display'));
//alert(getStyle(oFl,'display') == 'block');
if(getStyle(oFl,'display') == 'block'){
oFl.style.display='none';
oFr.style.display='block';
}else{
oFl.style.display='block';
oFr.style.display='none';
}
};
};
function getStyle(obj,attr){
if (obj.currentStyle) {
return obj.currentStyle[sttr];
} else {
return getComputedStyle(obj, false)[attr];
}
}
return obj.currentStyle[attr];
而非return obj.currentStyle[sttr];