弹出提示窗口背景自动变暗(js文件)

// JavaScript Document
/**
 * 功能:显示提示窗口
 * 使用方法提示:
 * <script src="popAlert.js" language="javascript"></script>
 * <button onClick="showPop('今天天气真好呀')">test</button>
 */

  /**
   * 描述:显示提示层
   */
  var ifm=null;
 function showPop(info){
  if(ifm==null){
   ifm=document.createElement("<iframe allowTransparency='true' id='popframe' frameborder=0 marginheight=0 src='about:blank' marginwidth=0 hspace=0 vspace=0 scrolling=no></iframe>")
   ifm.style.width=screen.availWidth;
   ifm.style.height=screen.availHeight;
   ifm.style.position="absolute";
   ifm.style.left=0;
   ifm.style.top=0;
   ifm.name=ifm.uniqueID;
   document.body.appendChild(ifm); 
  }else{
   ifm.style.visibility="visible";
  }
  var win=window.frames[ifm.name];
  win.document.write("<body leftmargin=0 topmargin=0 οncοntextmenu='self.event.returnValue=false'><div id=popbg></div><div id=popbody></div></body>");
  win.document.body.style.backgroundColor="transparent";
  
  document.body.style.overflow="hidden";
  
  var pBody=win.document.body.children[1];
  var pBg=win.document.body.children[0]; 
  hideAllSelect();
  initBg(pBg); 
  initBody(pBody,info);  
 }
 
  /**
   * 描述:初始化背景层
   */
 function initBg(obj){
  with(obj.style){
   position="absolute";   
   left="0";
   top="0";
   width="100%";
   height="100%";
   visibility="hidden";
   backgroundColor="#000000";
   filter="blendTrans(duration=2) alpha(opacity=50)";
  }
  
  if (obj.filters.blendTrans.status != 2) {//no playing
   obj.filters.blendTrans.apply();
   obj.style.visibility="visible";
   obj.filters.blendTrans.play();
  }


 }
  /**
   * 描述:初始化显示层
   */
 function initBody(obj,info){
  with(obj.style){
   position="absolute";
   width="400";
   height="150";
   backgroundColor="#ffffff";   
  }
  obj.style.left=window.document.body.clientWidth/2-200;
  obj.style.top=window.document.body.clientHeight/3;
  var str;
  str="<table border=0 cellpadding=0 cellspacing=1 bgcolor=#000000 width=100% height=100%><tr height=20>";
  str+="<td align=center style='color:#000000;font-size:14px;font-weight:bold' bgcolor=#9999ff>...:::提示:::...</td></tr>";
  str+="<tr><td align=center bgcolor=#efefff style='font-size:12px;color:#000000;vertical-align: bottom;'>";
  str+=info+"<br><br><button οnclick='parent.closeWin()'>确定</button><br><br></td></tr></table>";
  obj.innerHTML=str;
 }
 
  /**
   * 描述:关闭一切
   */
  function closeWin(){
   ifm.style.visibility="hidden";    
   showAllSelect();
   document.body.style.overflow="auto";  
   }
    function hideAllSelect(){
    var obj;
    obj=document.getElementsByTagName("SELECT");
    var i;
    for(i=0;i<obj.length;i++)
   obj[i].style.visibility="hidden";
    }
    function showAllSelect(){
    var obj;
    obj=document.getElementsByTagName("SELECT");
    var i;
    for(i=0;i<obj.length;i++)
   obj[i].style.visibility="visible";
    }
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值