currentStyle 1. Composite style: currentStyle cannot get Example: background, margin 2. Get the default style 3. Can only read Copy code The code is as follows: Get the calculated style <br>#div1{ height:100px; background:#069;} <br> <br>//Compatible<br>function getStyle(obj , name) <br>{ <br>if(obj.currentStyle) <br>{ <br>return obj.currentStyle[name]; <br>} <br>else <br>{ <br>return getComputedStyle(obj , false)[name]; <br>} <br>} <br>window.onload=function() <br>{ <br>var oDiv=document.getElementById('div1'); <br>alert(getStyle (oDiv, 'width')); <br>alert(getStyle(oDiv, 'backgroundColor')); //Note that when obtaining the composite style, you must write it separately, not background <br>}; <br></ script> <br></head> <br><body> <br><div id="div1"></div> <br></body> <br></html> ; <br> </div>