js中怎么改变外部css中的属性值

这是DIV登录框示例

<br> function openLogin(obj, attr){<br><br> if(obj.currentStyle) <br> { <br> window.alert(obj.currentStyle[attr]);<br> return obj.currentStyle[attr]; <br> } <br> else <br> { <br> return getComputedStyle(obj,false)[attr]; <br> } </p> <pre><code> } function closeLogin(){ } window.onload=function() { var oDiv=document.getElementById(&quot;w&quot;); alert(openLogin(oDiv,&quot;display&quot;)) } &lt;/script&gt; 百度上找的代码 这样只能获取display的值 请问怎么修改这个值 </code></pre>

 <style>.win{display:none}</style>
<div id="w" class="win">
        这是DIV登录框示例<br>
 </div>
 <script>
     function changecss(theClass, element, value) {
         var cssRules;
         if (document.all) {
             cssRules = 'rules';
         }
         else if (document.getElementById) {
             cssRules = 'cssRules';
         }
         for (var S = 0; S < document.styleSheets.length; S++) {
             for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
                 if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
                     document.styleSheets[S][cssRules][R].style[element] = value;
                 }
             }
         }
     }
     window.onload = function () {
         changecss('.win', 'display', 'block');
     } 
    </script>