javascript 函数

   document.defaultView.getComputedStyle 这是w3c标准方法,取得元素的样式信息,因为有些样式是在外部css文件定义的,所以用element.style是取不到的 如果是IE,可以用 element.currentStyle["name"]  

 

getComputedStyle is a method within theDOM Style specification which provides access to the final computed style of any element within a document. This is helpful because frequently styles may apply to an element from multiple sources. Using the computed style lets you know all of the final styles and final absolute values which applied to the element.

currentStyle is an older API which IE previously supported to retrieve the cascaded style of an element. Cascaded style values are similar to computed values however, they are not always returned in absolute values. For example, in this page, the cascaded value of the width of the source div is 75% but the computed value is given in terms of pixels and will change if you change the width of the page. Another difference to notice between computed and current values is for the height of the source div. The computed height is given in pixel units but the cascaded height simply has a value of "auto" as it is actually not specified in the css anywhere.

 

你可能感兴趣的:(JavaScript,css,api,IE,Access,styles)