the difference between 1:rules and cssrules:
Copy Code code as follows:
function Addcssrule (css,key,value) {
var css = document.stylesheets[document.stylesheets.length-1];
if (Navigator.userAgent.indexOf ("Firefox") >0)
{
Css.insertrule (key+ "{" +value+ "}", Css.cssRules.length)
}
Else
{
Css.addrules (Key,value);
}
}
function Removecssrule (key) {
for (var i = 0; i < document.styleSheets.length; i++) {
var css = document.stylesheets[i];
Navigator.userAgent.indexOf ("Firefox") >0?
(function () {
for (var j = 0; J < Css.cssRules.length; J + +) {
if (Css.cssrules[j].selectortext==key) {
Css.deleterule (j);
}
}
})() :
(Css.removerule (key));
}
}
I have added a way to solve this problem.
2: Firefox and IE to obtain background color problems (getComputedStyle and Currentstyle differences)
Copy Code code as follows:
function Getcurrentstyle (oelement) {
if (Navigator.userAgent.indexOf ("Firefox") >0) {
var rgbstr=document.defaultview.getcomputedstyle (oelement,null). BackgroundColor;
var strr;
if (rgbstr.tostring (). IndexOf (') >0 && rgbstr.tostring (). IndexOf (') ') >0)
{
Strr= rgbstr.tostring (). substring (parseint (rgbstr.tostring (). IndexOf (' (') +1), rgbstr.tostring (). IndexOf (') '). Split (', ');
}
Return Tohexcolor (strr[0],strr[1],strr[2]). substring (1);
}
else{
Return OElement.currentStyle.backgroundColor.trim (). substring (1);
}
}
Copy Code code as follows:
function Tohexcolor (r,g,b) {
var hex= ' # ';
var hexstr = ' 0123456789ABCDEF ';
Low = r% 16;
High = (R-low)/16;
Hex+=hexstr.charat (High) + Hexstr.charat (low);
Low = g% 16;
High = (G-low)/16;
Hex+=hexstr.charat (High) + Hexstr.charat (low);
Low = b% 16;
High = (B-low)/16;
Hex+=hexstr.charat (High) + Hexstr.charat (low);
return hex;
}
Remember that Firefox rgbstr is RGB so I'm going to turn it into 16. I also sorted out a very stupid conversion method and then looked at the blow to shoot bricks!