- From: Michael A. Puls II <shadow2531@gmail.com>
- Date: Wed, 23 Sep 2009 18:31:23 -0400
- To: "Garrett Smith" <dhtmlkitchen@gmail.com>, Øyvind Stenhaug <oyvinds@opera.com>
- Cc: www-style <www-style@w3.org>
On Wed, 23 Sep 2009 17:02:54 -0400, Garrett Smith <dhtmlkitchen@gmail.com>
wrote:
> document.defaultView.getComputedStyle is too verbose and clunky and
> getComputedStyle is shorter and simpler.
The document.defaultView.getComputedStyle way can be used for stuff like
this:
Element.prototype.getComputedStyle = function(property) {
return this.ownerDocument.defaultView.getComputedStyle(this,
null).getPropertyValue(property);
};
// or even
Element.prototype.getStyle = Element.prototype.getComputedStyle;
window.onload = function() {
alert(document.body.getComputedStyle("width"));
alert(document.body.getStyle("width"));
};
, where this.ownerDocument.defaultView.getComputedStyle feels more correct
than just getComputedStyle(), even if the latter works.
--
Michael
Received on Wednesday, 23 September 2009 22:32:12 UTC