可拖动、可关闭、透明标题的DIV弹出窗口,完美兼容各个浏览器

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<meta name="keywords" content="统御至诚科技股份公司-okit项目管理软件" />
<meta name="description" content="统御至诚科技股份公司-okit项目管理软件" />
<title>可拖动、可关闭、透明标题DIV百变窗口 </title>
<style type="text/css">
.mask{position: absolute;
top: 0px;
left: 0px;
filter: alpha(opacity=50);
-moz-opacity:0.5;
opacity:0.5;
background-color: #ffffff;
z-index: 2;
display: none;}


 /*  弹出基本资料div----最优秀的国产项目管理软件-okit统御项目管理软件,统御至诚科技股份公司研制。欢迎试用:www.kingrein.com */
div.sample_popup {height:auto; border: 1px solid #327eca; width: 300px;  }
div.menu_form_header{
 background: url('/image/1.jpg') repeat-x;
}
div.sample_popup div.menu_form_header
{
  border-bottom: 0px;
  cursor: default;
   width:100%;
  height:      22px;
  line-height: 22px;
  vertical-align: middle;
  text-decoration: none;
  font-family: "Times New Roman", Serif;
  font-weight: 800;
  font-size: 13px;
  color: #206040;
}
div.menu_form_body
{
  width:485px;
  height:450px;
  font-size:12px;
  background-color:#f1f8fe;
  border-top:1px solid #327eca;
  padding : 5px;
}
div.sample_popup input.menu_form_exit
{
  float: right;
  margin: 4px 5px 0px 0px;
  cursor: pointer;
}
/*end:  弹出商品信息div */
    </style>
<script type="text/javascript">
/**************************************************
 * DivWindow.js
 **************************************************/
 //最优秀的国产项目管理软件-okit统御项目管理软件,统御至诚科技股份公司研制。欢迎试用:www.kingrein.com
var DivWindow= function(
popup/*最外层div id*/,popup_drag/*拖动div id*/,popup_exit/*退出按钮id*/ ,exitButton/*触发服务器端退出按钮id*/,varwidth,varheight,zindex){
 this.popup =popup ; //窗口名称
 this.popup_drag=popup_drag;
 this.height =varheight ; //窗口高度,并没用来设置窗口高度宽度,用来定位在屏幕的位置
 this.width =varwidth ; //窗口宽度
 this.popup_exit=popup_exit;
 this.exitButton=exitButton;
 this.zindex=zindex;
 this.init = function(){ //初始化窗口
 this.popupShow();
 this.startDrag(); //设置拖动
 this.setCommond(); //设置关闭
 DivWindow.ArrayW.push(document.getElementById(this.popup)); //存储窗口到数组
 };this.init();
};
//存储窗口到数组
DivWindow.ArrayW = new Array();
//字符串连接类
DivWindow.StringBuild = function(){
 this.arr = new Array();
 this.push = function(str){
  this.arr.push(str);
 };
 this.toString = function(){
  return this.arr.join("");
 };
};
//拖动类
DivWindow.Drag = function(o ,oRoot){
 var _self = this;
 //拖动对象
 this.obj = (typeof oRoot != "undefined") ?oRoot : o;
 this.relLeft = 0; //记录横坐标
 this.relTop = 0; //记录纵坐标
 o.onselectstart = function(){
  return false;
 };
 o.onmousedown = function(e){ //鼠标按下
  e = _self.fixE(e);
  _self.relLeft = e.clientX - _self.fixU(_self.obj.style.left);
  _self.relTop = e.clientY - _self.fixU(_self.obj.style.top);
  document.onmousemove = function(e){
   _self.drag(e);
   //_self.obj.style.border = "1px dashed #000000";
   //_self.obj.style.filter = "alpha(opacity=30)";
   //_self.obj.style.opacity = "0.3";
  };
  document.onmouseup  = function(){
   _self.end();
   //_self.obj.style.border = "1px solid #cccccc";
   //_self.obj.style.borderBottom = "2px solid #E0E0E0";
   //_self.obj.style.borderRight = "2px solid #E0E0E0";
   //_self.obj.style.filter = "alpha(opacity=100)";
   //_self.obj.style.opacity = "1";
  };
 };
 this.drag = function(e){ //拖动
  e = this.fixE(e);
  var l = e.clientX - this.relLeft;
  var t = e.clientY - this.relTop;
  if (t < 0)
  {
   t = 0; //防止头部消失
  }
  this.obj.style.left = l +"px";
  this.obj.style.top = t +"px";
 };
 this.end = function(){ //结束拖动
  document.onmousemove = null;
  document.onmouseup = null;
 };
 this.fixE = function(e){ //修复事件
  if (typeof e == "undefined") e = window.event;
  return e;
 };
 this.fixU = function(u){ //处理px单位
  return parseInt(u.split("p")[0]);
 };
};
//窗口拖动
DivWindow.prototype.startDrag = function(){
 var obj = document.getElementById(this.popup);
        var drag = document.getElementById(this.popup_drag);
 new DivWindow.Drag(drag,obj);
};
//设定窗口优先级
DivWindow.prototype.setTop = function(){
 document.getElementById(this.popup).onclick =
 document.getElementById(this.popup).onmousedown =
 function(){
  for(var i=0;i<DivWindow.ArrayW.length;i++)
  {
   DivWindow.ArrayW[i].style.zIndex = 1;
  }
  this.style.zIndex = 100;
 };
};
//显示
DivWindow.prototype.popupShow=function()
{       document.getElementById('mask').style.display="block";
        document.getElementById('mask').style.width=window.screen.width +20;
        document.getElementById('mask').style.height=window.screen.width +20;
        var  element      = document.getElementById(this.popup);
        element.style.position   = "absolute";
        element.style.visibility = "visible";
        element.style.display    = "block";
        element.style.width=this.width;
        element.style.height='auto';
        element.style.left = (window.screen.width - this.width)/2+"px";
        //element.style.top  =(window.screen.height-this.height-100)/2+"px";
         element.style.top  =20+"px";
        element.style.zIndex=this.zindex;
}
//设置关闭
DivWindow.prototype.setCommond = function(){
 var _self = this;
 //根对象
 var obj = document.getElementById(this.popup);
 var exit = document.getElementById(this.popup_exit);
 var triggServerEvent=document.getElementById(this.exitButton);
//最优秀的国产项目管理软件-okit统御项目管理软件,统御至诚科技股份公司研制。欢迎试用:www.kingrein.com
 //设置关闭
             exit.onclick = function(){
      obj.style.display = "none";
      obj.style.visibility = 'hidden';
                    document.all.mask.style.display='none'//关闭遮罩层
     };
};
//最优秀的国产项目管理软件-okit统御项目管理软件,统御至诚科技股份公司研制。欢迎试用:www.kingrein.com
</script>
</head>
<body>
<a href="http://www.kingrein.com">okit项目管理软件</a>,国内最完善的项目管理软件,欢迎试用。<hr>
<!--//最优秀的国产项目管理软件-okit统御项目管理软件,统御至诚科技股份公司研制。欢迎试用:www.kingrein.com-->
<div>
 <input type="button"  id="show" οnclick="javascript:new DivWindow('popup','popup_drag','popup_exit','exitButton','500','700',4);"  value='点击弹出窗口'   />
</div>
  <!-- 遮罩层 -->
 <div id="mask"  class="mask">
 </div>
<!-- 弹出基本资料详细DIV层 -->
<div class="sample_popup"     id="popup" style="visibility: hidden; display: none;">
<div class="menu_form_header" id="popup_drag" style='cursor:pointer;'>
 
<div style="float:left;" >可拖动透明标题窗口</div><div id="popup_exit" style="float:right;margin-right:10px;"> X </div>
</div>
<div class="menu_form_body" >
 <div id="popDetail">
  软件名称:<a href="http://www.kingrein.com">统御项目管理系统(oKit) 2.0.0.1[一款IT项目管理软件]</a><br>
软件大小:84960 KB<br>
软件类型:国产软件<br>
授权方式:免费软件<br>
界面语言:简体中文<br>
运行环境:Win2003,WinXP,Win2000,Win9X<br>
软件介绍:<br>
        统御项目管理系统(oKit)是北京统御至诚科技股份公司<br>自主研发的IT项目管理软件产品。 <br>
它为用户管理好项目提供全面有力的支持,并能协助用户在<br>组织内部实施高效的项目化管理方法。<br>
  oKit是一套强大的项目管理工具、一个全面的信息中心、一个迅<br>捷的沟通平台,它融入了诸多先进的科学的管....
<img src="http://www.gezila.com/uploads/allimg/120116/1038-120116135110A0.jpg" width=440 height=250>

   


 </div>
</div>
</div>
<!-- 弹出基本资料详细DIV层 -->
<div class="sample_popup"     id="Div1" style="visibility: hidden; display: none;">
<div class="menu_form_header" id="Div2">
 <input type="button"  id="exit2" value="退出"
          />
</div>
<div class="menu_form_body" >
 <div id="Div3">
  最优秀的国产项目管理软件-okit统御项目管理软件,统御至诚科技股份公司研制。欢迎试用:www.kingrein.com:<a href="http://www.kingrein。com">www.kingrein.com</a>
温馨提示,这个窗口可以拖动
 </div>
</div>
</div>
</body>
</html>
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值