Web/API/Element/currentStyle

From Get docs

Non-standard This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.


Element.currentStyle is a proprietary property which is similar to the standardized window.getComputedStyle() method. It is available in old versions of Microsoft Internet Explorer. However, it returns the units set in CSS while window.getComputedStyle() returns the values in pixels.

Polyfill

This polyfill returns the values in pixels and is likely to be rather slow, as it has to call window.getComputedStyle() every time its value is read.


/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

if (!("currentStyle" in Element.prototype)) {
  Object.defineProperty(Element.prototype, "currentStyle", {
    get: function() {
      return window.getComputedStyle(this);
    }
  });
}

Specification

Not part of any specification.

Microsoft had a description on MSDN.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

currentStyle

Non-standard'

Chrome

No support No

Edge

No support No

Firefox

No support No

IE

Full support 6

Opera

No support No

Safari

No support No

WebView Android

No support No

Chrome Android

No support No

Firefox Android

No support No

Opera Android

No support No

Safari iOS

No support No

Samsung Internet Android

No support No

Legend

Full support  
Full support
No support  
No support
Non-standard. Expect poor cross-browser support.'
Non-standard. Expect poor cross-browser support.


See also