Archive for July 27th, 2007

Computed vs Cascaded Style

Friday, July 27th, 2007

Most JS frameworks and libraries I’ve seen have a function similar to this:
function getStyle(el, prop) {
if (document.defaultView && document.defaultView.getComputedStyle) {
return document.defaultView.getComputedStyle(el, null)[prop];
} else if (el.currentStyle) {
return el.currentStyle[prop];
} else {
return el.style[prop];
}
}
So what is wrong with this [...]