日期:2014-05-16  浏览次数:20441 次

美化js系统函数alert,confirm,prompt,并实现lightbox效果(http://blog.csdn.net/showbo/archive/)
view plaincopy to clipboardprint?
var Showbo={author:'showbo',homepage:'http://www.code-design.cn'}; 
//是否为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='<iframe src="javascript:false" mce_src="javascript:false" style="position:absolute; visibility:inherit; top:0px;left:0px;width:100%; height:100%; z-index:-1;' 
          +'filter=\'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)\';"></iframe>', 
      html='<div class="top"><div class="right"><div class="title" id="dvMsgTitle"></div></div></div>'+ 
  &nbs