如何处理IE中多次刷新函数的框背景颜色


function first(Objs) {            
         var imgid= Objs;                
         secondMethod(imgid);             
     }
function secondmethod(imgid) {
        var boxid=imgid.id;
        var color = getBackgroundColor(imgid.status);//am passing different colors for every refreshing(i.e. #D03C78 or #B8B8B8) values from DataBase 
        if($('#boxcontent'+boxid).is(':visible')) {
        }else{
    var boxText = document.createElement("div");
    boxText.id='boxcontent'+boxid;
    boxText.style.cssText = "white-space:nowrap;text-align:center;border:2px solid ;background-color:"+color+";opacity:0.9;filter:alpha(opacity=90);-moz-border-radius: 5px;border-radius: 5px;color:black !important;";
    return boxText;
        }
        $('#boxcontent'+boxid).css({'background-color':color});
     }
  • 这个盒子的内容显示在地图上
  • 这个盒子的背景颜色没有进入IE,但在FireFox中有效
  • 第一个功能是每隔10秒用不同的对象刷新一次。(针对每一种令人耳目一新的颜色变化(
  • 在IE不工作(即颜色不更改(时,请帮助解决此问题
  • 检查是否每10秒刷新一次
  • 你说过每10秒就会得到不同的物体
  • IE可能会遇到重新发送数据(刷新时(的问题,即缓存问题

var color = getBackgroundColor(imgid.status);//am passing different colors for every refreshing(i.e. #D03C78 or #B8B8B8) values from DataBase alert(imgid.id+" : color is : "+color)

  • 让我们在Firefox和IE中检查一下

很难说,为什么IE不使用您提供的信息设置颜色。。。也可能是css错误或缺少逗号等。但我会尽力帮你的。。JS和JQuery有一个奇怪的混合,所以我试图将其合并到JQuery中,因为它为IE提供了一些X-Browser的东西。。我还上了一节课,因为这样更干净。

//Some definition
var Objs = {
    id : 'test',
    status : "red"
};
//Call
first(Objs);
function first(Objs) {            
    var imgid= Objs;                
    secondMethod(imgid);             
}
function secondMethod(imgid) {
    var boxid = imgid.id;
    var color = imgid.status;
    if($('#boxcontent' + boxid).length < 1) { //No existing box, make new
        var boxText = $("<div></div>")
            .attr("id", "boxcontent"+boxid)
            .addClass("basciStyleNoColor")
            .css({
                'background-color' : color,
                opacity : 0.9 //<<-- Jquery sets filter for IE...
            });
        $("body").append(boxText);//<<-Insert here, or retrun and insert later...
        return boxText;
    }
}

CSS:

.basciStyleNoColor {
    white-space:nowrap;
    text-align:center;
    border:2px solid ;
    -moz-border-radius: 5px;
    border-radius: 5px;
    color:black !important;    
}

这里是Fiddle.net

希望它能帮助一些人如何。。。

最新更新