欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

firefox火狐瀏覽器與與ie兼容的2個問題總結

 更新時間:2010年07月20日 00:40:06   作者:  
這幾天遇到幾個頭疼的火狐與ie兼容問題整理下來,希望對需要的朋友有所幫助。
1:rules與cssRules區(qū)別:
復制代碼 代碼如下:

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)) ;
}
}

我是這樣加了一個方法解決這個問題的。。
2:火狐和ie中獲得背景色問題(getComputedStyle與currentStyle的區(qū)別)
復制代碼 代碼如下:

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);
}
}

復制代碼 代碼如下:

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;
}

記住 火狐獲得的rgbstr是rgb的因此我還要轉成16進制的。我也整理了一個很笨的轉換方法再上面望打擊拍磚!

相關文章

最新評論