var pColor= document.styleSheets[document.styleSheets.length-1];
alert(pColor);
alert(pColor.rules);
再ie中 都是有值的 可是再火狐中下面这个alert(pColor.rules);是没有值的 我使用的是 Ext的 Ext.menu.ColorItem 请教大家 倒是是为啥?
alert(pColor);
alert(pColor.rules);
再ie中 都是有值的 可是再火狐中下面这个alert(pColor.rules);是没有值的 我使用的是 Ext的 Ext.menu.ColorItem 请教大家 倒是是为啥?
a,div,p {color:red}
h5 {color:blue}
</style>
<script>
if(document.styleSheets[0].cssRules){
alert(document.styleSheets[0].cssRules[1].selectorText+":"+document.styleSheets[0].cssRules[1].style.cssText)
}else{
alert(document.styleSheets[0].rules[1].selectorText+":"+document.styleSheets[0].rules[1].style.cssText)
}
</script>
new Ext.Button({
text:'选择颜色',
id:'SketchLineColor',
cls: 'sketchContentName2',
width:90,
menu: {
items: [
new Ext.menu.ColorItem({listeners:{"click":function(baseitem, evt){
var color=baseitem.component.value;
var pColor= document.styleSheets[document.styleSheets.length-1];
alert(pColor);
alert(pColor.rules);
if(pColor.rules[pColor.rules.length-1].selectorText == ".SketchLineColorlab")
pColor.removeRule(pColor.rules.length-1);
pColor.addRule('.SketchLineColorlab','background-color:'+ '#' + color +'');
Ext.getCmp("SketchLineColorlab").render();
}},scope:this}), '-'
//{text:'More Colors...'}
]
}
})
我觉得 应该是 rules 第几个选择器 可是 上面这段为啥 再ie中可以。。再火狐中不行呢?
cssRules 在firefox中
4楼都已经写了。
items: [
new Ext.menu.ColorItem({listeners:{"click":function(baseitem, evt){
var color=baseitem.component.value;
var pColor= document.styleSheets[document.styleSheets.length-1];
if(pColor.cssRules[pColor.cssRules.length-1].selectorText == ".SketchLineColorlab")
pColor.removeRule(pColor.cssRules.length-1);
pColor.addRules('.SketchLineColorlab','background-color:'+ '#' + color +'');
Ext.getCmp("SketchLineColorlab").render();
}},scope:this}), '-'
//{text:'More Colors...'}
]
报 是报这句错误 pColor.addRules()没这个方法。。难度 要改成 pColor.addcssRules
if(pColor.cssRules[pColor.cssRules.length-1].selectorText == ".SketchLineColorlab")
pColor.removeRule(pColor.cssRules.length-1);大家 给点 解释啊?