1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  2.    
  3. <html xmlns="http://www.w3.org/1999/xhtml"> 
  4.    
  5. <head> 
  6.    
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  8.    
  9. <title></title> 
  10.    
  11. <style type="text/css"> 
  12.    
  13. #test{  
  14.    
  15. background-color:#9F3;  
  16.    
  17. width:500px;  
  18.    
  19. height:400px;  
  20.    
  21. }  
  22.    
  23. </style> 
  24.    
  25. <script type="text/javascript"> 
  26.    
  27. window.onload=function(){  
  28.    
  29. obj=document.getElementById('test');  
  30.    
  31. if(document.all){  
  32.    
  33. alert(obj.currentStyle.backgroundColor);  
  34.    
  35. }else{  
  36.    
  37. alert(window.getComputedStyle(obj,null).getPropertyValue('background-color'));  
  38.    
  39. }  
  40.    
  41. }  
  42.    
  43. </script> 
  44.    
  45. </head> 
  46.    
  47. <body> 
  48.    
  49. <div id="test">测试currentStyle!!</div> 
  50.    
  51. </body> 
  52.    
  53. </html> 
  54.    
  55.