javascript 通过封装div方式弹出div窗体

时间:2021-05-26

图1(弹出一个div)

图2(弹出多个)
构造函数:
复制代码 代码如下:
var DivWindow= function(popup,popup_drag,popup_exit ,exitButton,varwidth,varheight,zindex){
this.popup =popup ;
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();
};

调用:
复制代码 代码如下:
<input type="button" id="show" onclick="javascript:new DivWindow('popup','popup_drag','popup_exit','exitButton','500','700',4);" value='触发弹出详细基本资料DIV' />

有的地方可能大家觉得有点奇怪,不要问我问什么,因为我有这个需要,有时间再修改一下遮罩效果。更详细代码请见下载
完整代码
窗口类 .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.sample_popup {height:auto; border: 1px solid #327eca; width: 300px; } div.menu_form_header{ background: url('../images/baseInfo/titleBG.gif') 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:100%; height:150px; font-size:12px; background-color:#f1f8fe; } div.sample_popup input.menu_form_exit { float: right; margin: 4px 5px 0px 0px; cursor: pointer; }

立即联系我

立即提交