currentStyle getComputedStyle

注意:getComputedStyle是firefox中的,

      currentStyle是ie中的.

 

比如说

<style>

     #mydiv {

            width : 300px;

     }

</styke>

 

则:

var mydiv = document.getElementById('mydiv');

if(mydiv.currentStyle) {

      var width = mydiv.currentStyle['width'];

      alert('ie:' + width);

} else if(window.getComputedStyle) {

      var width = window.getComputedStyle(mydiv , null)['width'];

      alert('firefox:' + width);

}

你可能感兴趣的:(IE,firefox)