修改js确认框样式

css代码

/* CSS Document */
body,h1,h2,h3,h4,h5,h6,p,ul,ol,li,form,img,dl,dt,dd,table,th,td,blockquote,fieldset,div,strong,label,em{margin:0;padding:0;border:0;}
ul,ol,li{list-style:none;}
input,button{margin:0;font-size:12px;vertical-align:middle;}
body{font-size:12px;font-family:Arial, Helvetica, sans-serif; color:#333; margin:0 auto; }
table{border-collapse:collapse;border-spacing:0;}

a{color:#333;text-decoration:none;}
a:hover{color:#c00; text-decoration:underline;}

.box-163css{ width:350px; margin:220px auto; position:relative;}
.box-163css input{ margin-left:10px; border:none; border:1px solid #a10000; background:#c00; text-align:center; height:24px; line-height:20px; color:#fff; cursor:pointer;}
#dvMsgBox{display:none;position:absolute;font-size:12px;width:300px;overflow:hidden;z-index:999; border-radius:3px; font-family:微软雅黑;}
#dvMsgBox .top{height:40px; background-color:#72D1FF;padding-left:16px; float:left; width:100%;}
#dvMsgBox .top .right{height:100%;padding-right:6px;}
#dvMsgBox .top .right .title{height:100%;line-height:40px;color:#fff;vertical-align:middle;font-size:14px;overflow:hidden;}
#dvMsgBox .body{background:#fff;padding-left:10px;}
#dvMsgBox .body .right{background:#fff;padding-right:2px;}
#dvMsgBox .body .right .ct{ line-height: 60px;
vertical-align: middle;
width: 100%;
text-align: center;
color:#2b9bc5;
font-size: 14px;}
#dvMsgBox .body .right .ct .pro{width:280px;border:solid 1px #6593cf;height:25px;background:#ffffff;line-height:23px;overflow:hidden;}
#dvMsgBox .body .right .ct .pro .bg{width:0%;height:100%;background:#c9dffc;}
#dvMsgBox .bottom{background:#fff;padding-left:6px;}
#dvMsgBox .bottom .right{height:100%;/*background:transparent url(right-corners.png) no-repeat right bottom;*/padding-right:6px;}
input.btn{width:56px; border-radius: 3px; font-family:微软雅黑; cursor:pointer; color:#fff; border:none; height:25px; text-align:center; background-color:#72D1FF;text-align:center; margin:0px auto;}
input.btnfocus{ background-color:#EC6D51; font-family:微软雅黑; border-radius: 3px;width:56px;margin:0px auto; border:none; height:25px; cursor:pointer; color:#fff;}
#dvMsgBox .icon{width:32px;height:32px;float:left;margin-right:10px;}
#dvMsgBox .error{background:url(icon-error.gif) no-repeat;}
#dvMsgBox .info{background:url(icon-info.gif) no-repeat;}
#dvMsgBox .warning{background:url(icon-warning.gif) no-repeat;}
#dvMsgBox .clear{clear:both;}
#dvMsgBox .height{height:10px;line-height:10px;}
#ShowBolightBox{display:none;-moz-opacity:0.5;filter:alpha(opacity=50);opacity:0.5;background-color:#000000;z-index:100;position:absolute;left:0px;top:0px;}
#dvMsgBtns{ text-align:center; width:100%;}

 

js代码

var Showbo={author:'showbo',homepage:'http://www.lenomC100.com'};
//是否为ie浏览器
Showbo.IsIE=!!document.all;
//ie浏览器版本
Showbo.IEVersion=(function(){if(!Showbo.IsIE)return -1;try{return parseFloat(/msie ([\d\.]+)/i.exec(navigator.userAgent)[1]);}catch(e){return -1;}})();
//按id获取对象
Showbo.$=function(Id,isFrame){var o;if("string"==typeof(Id))o= document.getElementById(Id);else if("object"==typeof(Id))o= Id;else return null;return isFrame?(Showbo.IsIE?frames[Id]:o.contentWindow):o;}
//按标签名称获取对象
//页面的高和宽******************************
Showbo.isStrict=document.compatMode == "CSS1Compat";
Showbo.BodyScale={x:0,y:0,tx:0,ty:0};//(x,y):当前的浏览器容器大小 (tx,ty):总的页面滚动宽度和高度
Showbo.getClientHeight=function(){/*if(Showbo.IsIE)*/return Showbo.isStrict ? document.documentElement.clientHeight :document.body.clientHeight;/*else return self.innerHeight;*/}
Showbo.getScrollHeight=function(){var h=!Showbo.isStrict?document.body.scrollHeight:document.documentElement.scrollHeight;return Math.max(h,this.getClientHeight());}
Showbo.getHeight=function(full){return full?this.getScrollHeight():this.getClientHeight();}
Showbo.getClientWidth=function(){/*if(Showbo.IsIE)*/return Showbo.isStrict?document.documentElement.clientWidth:document.body.clientWidth;/*else return self.innerWidth;*/}
Showbo.getScrollWidth=function(){var w=!Showbo.isStrict?document.body.scrollWidth:document.documentElement.scrollWidth;return Math.max(w,this.getClientWidth());}
Showbo.getWidth=function(full){return full?this.getScrollWidth():this.getClientWidth();}
Showbo.initBodyScale=function(){Showbo.BodyScale.x=Showbo.getWidth(false);Showbo.BodyScale.y=Showbo.getHeight(false);Showbo.BodyScale.tx=Showbo.getWidth(true);Showbo.BodyScale.ty=Showbo.getHeight(true);}
//页面的高和宽******************************
Showbo.Msg={
INFO:'info',
ERROR:'error',
WARNING:'warning',
IsInit:false,
timer:null,
dvTitle:null,
dvCT:null,
dvBottom:null,
dvBtns:null,
lightBox:null,
dvMsgBox:null,
defaultWidth:300,
moveProcessbar:function(){
var o=Showbo.$('dvProcessbar'),w=o.style.width;
if(w=='')w=20;
else{
w=parseInt(w)+20;
if(w>100)w=0;
}
o.style.width=w+'%';
},
InitMsg:function(width){
//ie下不按照添加事件的循序来执行,所以要注意在调用alert等方法时要检测是否已经初始化IsInit=true
var ifStr='',
html='

'+
'
'+
'
';
this.dvMsgBox=document.createElement("div");
this.dvMsgBox.id="dvMsgBox";
this.dvMsgBox.innerHTML+=html;
document.body.appendChild(this.dvMsgBox);
this.lightBox=document.createElement("div");
this.lightBox.id="ShowBolightBox";
document.body.appendChild(this.lightBox);
if(Showbo.IsIE&&Showbo.IEVersion<7){//加iframe层修正ie6下无法遮盖住select的问题
this.lightBox.innerHTML+=ifStr;
this.dvMsgBox.innerHTML+=ifStr;
}
this.dvBottom=Showbo.$('dvMsgBottom');
this.dvBtns=Showbo.$('dvMsgBtns');
this.dvCT=Showbo.$('dvMsgCT');
this.dvTitle=Showbo.$('dvMsgTitle');
this.IsInit=true;
},
checkDOMLast:function(){//此方法非常关键,要不无法显示弹出窗口。两个对象dvMsgBox和lightBox必须处在body的最后两个节点内
if(document.body.lastChild!=this.lightBox){
document.body.appendChild(this.dvMsgBox);
document.body.appendChild(this.lightBox);
}
},
createBtn:function(p,v,fn){
var btn=document.createElement("input");
btn.type="button";
btn.className='btn';
btn.value=v;
btn.οnmοuseοver=function(){this.className='btnfocus';}
btn.οnmοuseοut=function(){this.className='btn';}
btn.οnclick=function(){
Showbo.Msg.hide();
if(fn)fn(p);
}
return btn;
},
alert:function(msg){
this.show({buttons:{yes:'确认'},msg:msg,title:'消息'});
},
confirm:function(msg,fn){
//fn为回调函数,参数和show方法的一致
this.show({buttons:{yes:'确认',no:'取消'},msg:msg,title:'提示',fn:fn});
},
prompt:function(labelWord,defaultValue,txtId,fn){
if(!labelWord)labelWord='请输入:';
if(!defaultValue)defaultValue="";
if(!txtId)txtId="msg_txtInput";
this.show({title:'输入提示',msg:labelWord+'',buttons:{yes:'确认',no:'取消'},fn:fn});
},
wait:function(msg,title){
if(!msg)msg='正在处理..';
this.show({title:title,msg:msg,wait:true});
},
show:function(cfg){
//cfg:{title:'',msg:'',wait:true,icon:'默认为信息',buttons:{yes:'',no:''},fn:function(btn){回调函数,btn为点击的按钮,可以为yes,no},width:显示层的宽}
//如果是等待则wait后面的配置不需要了。。
if(!cfg)throw("没有指定配置文件!");
//添加窗体大小改变监听
if(Showbo.IsIE)window.attachEvent("onresize",this.onResize);
else window.addEventListener("resize",this.onResize,false);

if(!this.IsInit)this.InitMsg();//初始化dom对象
else this.checkDOMLast();//检查是否在最后

//检查是否要指定宽,默认为300
if(cfg.width)this.defaultWidth=cfg.width;
this.dvMsgBox.style.width=this.defaultWidth+'px';
//可以直接使用show方法停止为进度条的窗口
if(this.timer){clearInterval(this.timer);this.timer=null;}
this.dvTitle.innerHTML='';
if(cfg.title)this.dvTitle.innerHTML=cfg.title;
this.dvCT.innerHTML='';
if(cfg.wait){
if(cfg.msg)this.dvCT.innerHTML=cfg.msg;
this.dvCT.innerHTML+='
';
this.dvBtns.innerHTML='';
this.dvBottom.style.height='10px';
this.timer=setInterval(function(){Showbo.Msg.moveProcessbar();},1000);
}
else{
//if(!cfg.icon)cfg.icon=Showbo.Msg.INFO;
if(!cfg.buttons||(!cfg.buttons.yes&&!cfg.buttons.no)){
cfg.buttons={yes:'确定'};
}
if(cfg.icon)this.dvCT.innerHTML='
';
if(cfg.msg)this.dvCT.innerHTML+=cfg.msg+'
';
this.dvBottom.style.height='45px';
this.dvBtns.innerHTML='
';
if(cfg.buttons.yes){
this.dvBtns.appendChild(this.createBtn('yes',cfg.buttons.yes,cfg.fn));
if(cfg.buttons.no)this.dvBtns.appendChild(document.createTextNode(' '));
}
if(cfg.buttons.no)this.dvBtns.appendChild(this.createBtn('no',cfg.buttons.no,cfg.fn));
}
Showbo.initBodyScale();
this.dvMsgBox.style.display='block';
this.lightBox.style.display='block';
this.onResize(false);
},
hide:function(){
this.dvMsgBox.style.display='none';
this.lightBox.style.display='none';
if(this.timer){clearInterval(this.timer);this.timer=null;}
if(Showbo.IsIE)window.detachEvent('onresize',this.onResize);
else window.removeEventListener('resize',this.onResize,false);
},
onResize:function(isResize){
if(isResize)Showbo.initBodyScale();
Showbo.Msg.lightBox.style.width=Showbo.BodyScale.tx+'px';
Showbo.Msg.lightBox.style.height=Showbo.BodyScale.ty+'px';
Showbo.Msg.dvMsgBox.style.top=240+'px';
Showbo.Msg.dvMsgBox.style.left=Math.floor((Showbo.BodyScale.x-Showbo.Msg.dvMsgBox.offsetWidth)/2)+'px';
}

}

 

 

html




js alert confirm样式弹出框










适用浏览器:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗.



 

转载于:https://www.cnblogs.com/WORDPAD/p/5417081.html

你可能感兴趣的:(修改js确认框样式)