function getStyle(dom) {
var style;
var returns = {};
/**
* This statement determines whether computed style is available for the DOM element
*/
if (window.getComputedStyle) {
style = window.getComputedStyle(dom, null);
for (var i = 0; i < style.length; i++) {
var prop = style[i];
var val = style.getPropertyValue(prop);
returns[prop] = val;
}
return returns;
}
/**
* This statement determines whether inline style is available for the DOM element
*/
if (dom.currentStyle) {
style = dom.currentStyle;
for (var prop in style) {
returns[prop] = style[prop];
}
return returns;
}
/*
* This statement determines whether the style is specified within some stylesheet for the DOM element
*/
if (style = dom.style) {
for (var prop in style) {
if (typeof style[prop] != 'function') {
returns[prop] = style[prop];
}
}
return returns;
}
return returns;
}
var style;
var returns = {};
/**
* This statement determines whether computed style is available for the DOM element
*/
if (window.getComputedStyle) {
style = window.getComputedStyle(dom, null);
for (var i = 0; i < style.length; i++) {
var prop = style[i];
var val = style.getPropertyValue(prop);
returns[prop] = val;
}
return returns;
}
/**
* This statement determines whether inline style is available for the DOM element
*/
if (dom.currentStyle) {
style = dom.currentStyle;
for (var prop in style) {
returns[prop] = style[prop];
}
return returns;
}
/*
* This statement determines whether the style is specified within some stylesheet for the DOM element
*/
if (style = dom.style) {
for (var prop in style) {
if (typeof style[prop] != 'function') {
returns[prop] = style[prop];
}
}
return returns;
}
return returns;
}
Comments