基于Jquery的开发个代阴影的对话框效果代码 - Web前端
作者:98wpeu发布时间:2026-07-08分类:网页前端技术浏览:2
导读:复制代码代码如下:<scripttype="text/javascript"src="http://img.zzl.com/script/JQuery/jQuery-1....
复制代码 代码如下:
<scripttype="text/javascript" src="http://img.zzl.com/script/JQuery/jQuery-1.4.2.min.JS"></script>
<script type="text/JavaScript">
$(function() {
$("#open").click(function() {
opendialog(a1); //调用,直接写上DIV的ID即可
});
});
var openDialog = function(o) {
var dialog = new zzlDialog(o);
dialog.open();
}
var zzlDialog = function(o) {
this.init = function() {
/* 对话框初始化 */
var XBox = '\
<div id="mask"/>\
<div id="wAI">\
</div>\
<div id="nie">\
<table>\
<thead>\
<tr>\
<td>\
阴影弹出框\
</td>\
<td>\
</td>\
</tr>\
</thead>\
<tbody>\
<tr>\
<td colspan="2">' + $(o).html() + '\
</td>\
</tr>\
</tbody>\
</table>\
</div>\
';
$(document.body).append(XBox);
};
this.CSSInit = function() {
/* css初始化 */
$("#wai").css({ "padding": "10px", "background": "#000", "filter": "Alpha(Opacity='50')", "position": "absolute" });
$("#nIE").css({ "position": "absolute", "z-index": "1000" });
$("#nie>TABle").css({ "border": "1px solid rgb(55,119,188)", "border-collapse": "collapse", "background": "#fff" });
$("#nie>table>thead>tr").css({ "background": "rgb(0,94,172)", "color": "#fff", "height": "30px", "font-size": "14px", "font-weight": "bold" });
$("#nie>table").find("td").css({ "padding": "5"});
/* 内部主体定位 */
$("#nie").css({ "top": "50px" });
$("#nie").css({ "left": "50px" });
/* 关闭按钮 */
var $close = $("#nie>table>thead").find("td").next("td");
$close.HTML("<span>关闭</span>");
$close.css({ "text-align": "right", "padding-right": "5px" });
$close.find("span").css({ "font-weight": "normal", "cursor": "hand" });
$close.find("span").click(function() { new zzlDialog().closes(); });
/* 外部阴影添加 ,及位置和大小由内部内容来控制 */
$("#wai").css({ "width": ($("#nie>table").width() + 16) + "px", "height": ($("#nie>table").height() + 16) + "px" });
$("#wai").css({ "top": $("#nie").position().top - 8 + "px", "left": $("#nie").position().left - 8 + "px", "z-index": $("#nie").css("z-index") });
// $("#wai").corner("5px"); //圆角
};
this.open = function() {
this.init();
this.cssInit();
this.shadow();
};
this.shadow = function() {
this.event_b_show();
if (window.attachEvent) {
window.attachEvent('onresize', this.event_b);
window.attachEvent('onscroll', this.event_b);
}
else {
window.addEventListener('resize', this.event_b, false);
window.addEventlistener('scroll', this.event_b, false);
}
};
this.event_b = function() {
var oShadow = $('#mask');
if (oShadow.css("display") != "none") {
if (this.event_b_show) {
this.event_b_show();
}
}
};
this.closes = function() {
var oShadow = $('#mask');
oShadow.css({ 'display': 'none' });
$("#wai").remove();
$("#nie").remove();
};
this.event_b_show = function() {
var oShadow = $('#mask');
oShadow.css({ 'position': 'absolute', 'display': '', 'opacity': '0.1', 'filter': 'alpha(opacity=10)', 'background': '#000' });
var sclientWidth = parent ? parent.document.body.offsetWidth : document.body.offsetWidth;
var sClientHeight = parent ? parent.document.body.offsetHeight : document.body.offsetHeight;
var sscrollTop = parent ? (parent.document.body.scrollTop + parent.document.documentElement.scrollTop) : (document.body.scrollTop + document.documentElement.scrollTop);
oShadow.css({ 'top': '0px', 'left': '0px', 'width': sClientWidth + "px", 'height': (sClientHeight + sScrollTop) + "px" });
<scripttype="text/javascript" src="http://img.zzl.com/script/JQuery/jQuery-1.4.2.min.JS"></script>
<script type="text/JavaScript">
$(function() {
$("#open").click(function() {
opendialog(a1); //调用,直接写上DIV的ID即可
});
});
var openDialog = function(o) {
var dialog = new zzlDialog(o);
dialog.open();
}
var zzlDialog = function(o) {
this.init = function() {
/* 对话框初始化 */
var XBox = '\
<div id="mask"/>\
<div id="wAI">\
</div>\
<div id="nie">\
<table>\
<thead>\
<tr>\
<td>\
阴影弹出框\
</td>\
<td>\
</td>\
</tr>\
</thead>\
<tbody>\
<tr>\
<td colspan="2">' + $(o).html() + '\
</td>\
</tr>\
</tbody>\
</table>\
</div>\
';
$(document.body).append(XBox);
};
this.CSSInit = function() {
/* css初始化 */
$("#wai").css({ "padding": "10px", "background": "#000", "filter": "Alpha(Opacity='50')", "position": "absolute" });
$("#nIE").css({ "position": "absolute", "z-index": "1000" });
$("#nie>TABle").css({ "border": "1px solid rgb(55,119,188)", "border-collapse": "collapse", "background": "#fff" });
$("#nie>table>thead>tr").css({ "background": "rgb(0,94,172)", "color": "#fff", "height": "30px", "font-size": "14px", "font-weight": "bold" });
$("#nie>table").find("td").css({ "padding": "5"});
/* 内部主体定位 */
$("#nie").css({ "top": "50px" });
$("#nie").css({ "left": "50px" });
/* 关闭按钮 */
var $close = $("#nie>table>thead").find("td").next("td");
$close.HTML("<span>关闭</span>");
$close.css({ "text-align": "right", "padding-right": "5px" });
$close.find("span").css({ "font-weight": "normal", "cursor": "hand" });
$close.find("span").click(function() { new zzlDialog().closes(); });
/* 外部阴影添加 ,及位置和大小由内部内容来控制 */
$("#wai").css({ "width": ($("#nie>table").width() + 16) + "px", "height": ($("#nie>table").height() + 16) + "px" });
$("#wai").css({ "top": $("#nie").position().top - 8 + "px", "left": $("#nie").position().left - 8 + "px", "z-index": $("#nie").css("z-index") });
// $("#wai").corner("5px"); //圆角
};
this.open = function() {
this.init();
this.cssInit();
this.shadow();
};
this.shadow = function() {
this.event_b_show();
if (window.attachEvent) {
window.attachEvent('onresize', this.event_b);
window.attachEvent('onscroll', this.event_b);
}
else {
window.addEventListener('resize', this.event_b, false);
window.addEventlistener('scroll', this.event_b, false);
}
};
this.event_b = function() {
var oShadow = $('#mask');
if (oShadow.css("display") != "none") {
if (this.event_b_show) {
this.event_b_show();
}
}
};
this.closes = function() {
var oShadow = $('#mask');
oShadow.css({ 'display': 'none' });
$("#wai").remove();
$("#nie").remove();
};
this.event_b_show = function() {
var oShadow = $('#mask');
oShadow.css({ 'position': 'absolute', 'display': '', 'opacity': '0.1', 'filter': 'alpha(opacity=10)', 'background': '#000' });
var sclientWidth = parent ? parent.document.body.offsetWidth : document.body.offsetWidth;
var sClientHeight = parent ? parent.document.body.offsetHeight : document.body.offsetHeight;
var sscrollTop = parent ? (parent.document.body.scrollTop + parent.document.documentElement.scrollTop) : (document.body.scrollTop + document.documentElement.scrollTop);
oShadow.css({ 'top': '0px', 'left': '0px', 'width': sClientWidth + "px", 'height': (sClientHeight + sScrollTop) + "px" });
相关推荐
- 网页前端技术排行
-
- 1分析Iconfont-阿里巴巴矢量常用图标库 - Web前端
- 2【第六章】Foundation之按钮和下拉功能 - Web前端
- 3jQuery编写widget的一些技巧分享 - Web前端
- 4在Mac/PC上远程调试iPhone/iPad上的网页 - Web前端
- 5基于jquery的滚动条滚动固定div(附演示下载) - Web前端
- 6jQuery实例教程:制作网页中可折叠的面板 - Web前端
- 7分享精心挑选的12款优秀jQuery Ajax分页插件和教程 - Web前端
- 8[Web前端]用javascript实现默认图片替代未显示的图片 - Web前端
- 9javascript原生和jquery库实现iframe自适应高度和宽度 - Web前端
- 最近发表
-
- WordPress随机显示特色图片插件:Random Post Thumbnails
- KeePass实现Chrome浏览器自动填充密码方法一
- LNMP一键包nginx 301强制跳转到https教程
- KeePass实现Chrome浏览器自动填充密码方法二
- #建站# 免费的VPS管理软件Xshell8/Xftp8中文版下载
- 使用Xshell 8连接VPS教程_电脑登录vps的方法
- WordPress评论界面添加烟花????效果
- 不同浏览器书签同步方案:坚果云+Floccus_详细使用教程
- iOS端KeePassXC客户端APP:Strongbox Password Safe
- 给WordPress评论中的Gravatar头像图片添加ALT属性


