function getStyleProperty(obj, property){
var ele = document.getElementById(obj),
val = '';
//console.log(ele.ownerDocument.firstChild.innerHTML);
if(ele.currentStyle){
val = ele.currentStyle[property];
} else if(ele.ownerDocument.defaultView.getComputedStyle) { //找到节点所属的document再找到其所属的window
val = ele.ownerDocument.defaultView.getComputedStyle(ele, null).getPropertyValue(property);
}
alert(val || '没有此属性值');
//return val || '没有此属性值';
}
//console.log(document.defaultView);
//alert(getStyle('wrap', 'height'));
function getFullStyle(){
var ss = document.styleSheets[0]; //获得该文档的样式表,数组元素类型是CSSStyleSheet
var rules = ss.cssRules ? ss.cssRules : ss.rules; //FF是cssRules,IE是rules。rules代表样式表中的规则,类型是CSSRule
for(var i=0; i<rules.length; i++){
var rule = rules[i];
alert(rule.selectorText + '{' + rule.style.cssText.toLowerCase() + '}'); //selectorText css选择器的名称
//return rule.selectorText + ':{' + rule.style.cssText.toLowerCase() + '}'; //selectorText css选择器的名称
}
}
//getFullStyle();
var ele = document.getElementById(obj),
val = '';
//console.log(ele.ownerDocument.firstChild.innerHTML);
if(ele.currentStyle){
val = ele.currentStyle[property];
} else if(ele.ownerDocument.defaultView.getComputedStyle) { //找到节点所属的document再找到其所属的window
val = ele.ownerDocument.defaultView.getComputedStyle(ele, null).getPropertyValue(property);
}
alert(val || '没有此属性值');
//return val || '没有此属性值';
}
//console.log(document.defaultView);
//alert(getStyle('wrap', 'height'));
function getFullStyle(){
var ss = document.styleSheets[0]; //获得该文档的样式表,数组元素类型是CSSStyleSheet
var rules = ss.cssRules ? ss.cssRules : ss.rules; //FF是cssRules,IE是rules。rules代表样式表中的规则,类型是CSSRule
for(var i=0; i<rules.length; i++){
var rule = rules[i];
alert(rule.selectorText + '{' + rule.style.cssText.toLowerCase() + '}'); //selectorText css选择器的名称
//return rule.selectorText + ':{' + rule.style.cssText.toLowerCase() + '}'; //selectorText css选择器的名称
}
}
//getFullStyle();