极乐门资源网 Design By www.ioogu.com
页面比较丑,只把功能实现了。^ ^
复制代码 代码如下:
<title>模仿easyui dialog的效果</title>
<script>
//取得页面元素
var getElement = function() {
return document.getElementById(arguments[0]) || false;
}
function openDialog(dialogId) {
var maskId = "mask";
//如果有,先删除原来的
if (getElement(dialogId)) {
document.removeChild(getElement(dialogId));//删除操作:弹出的div
}
if (getElement(maskId)) {
document.removeChild(getElement(maskId));//删除操作:弹出的不可操作(面具)层
}
//背景置灰
var maskDiv = document.createElement("div");
maskDiv.id = maskId;
maskDiv.style.position = "absolute";
maskDiv.style.zIndex = "1";
maskDiv.style.width = document.body.scrollWidth + "px";
maskDiv.style.height = document.body.scrollHeight + "px";
maskDiv.style.top = "0px";
maskDiv.style.left = "0px";
maskDiv.style.background = "gray";
maskDiv.style.filter = "alpha(opacity=10)";
maskDiv.style.opacity = "0.30";//透明度
document.body.appendChild(maskDiv);//向body之中增加背景层
//Dialog
var dialogDiv = document.createElement("div");
dialogDiv.id = dialogId;
dialogDiv.style.position = "absolute";
dialogDiv.style.zIndex = "9999";
dialogDiv.style.width = "400px";
dialogDiv.style.height = "200px";
dialogDiv.style.top = (parseInt(document.body.scrollHeight) - 200) / 2 + "px"; // 屏幕居中
dialogDiv.style.left = (parseInt(document.body.scrollWidth) - 400) / 2 + "px"; // 屏幕居中
dialogDiv.style.background = "white";
dialogDiv.style.border = "1px solid gray";
dialogDiv.style.padding = "5px";
dialogDiv.innerHTML = "(Dialog Content)";
//Dialog之中的关闭操作:关闭背景层和Dialog层
var closeControlloer = document.createElement("a");//创建一个超链接(做为关闭的触发)
closeControlloer.href = "#";
closeControlloer.innerHTML = "关闭";
closeControlloer.onclick = function() {
document.body.removeChild(getElement(dialogId));//删除diaglog
document.body.removeChild(getElement(maskId));//删除背景层
}
dialogDiv.appendChild(closeControlloer);//dialog之中增加"关闭"操作
document.body.appendChild(dialogDiv);//body之中增加dialog
}
</script>
<a href="#" onclick="openDialog('dialog');">Open Dialog</a>
复制代码 代码如下:
<title>模仿easyui dialog的效果</title>
<script>
//取得页面元素
var getElement = function() {
return document.getElementById(arguments[0]) || false;
}
function openDialog(dialogId) {
var maskId = "mask";
//如果有,先删除原来的
if (getElement(dialogId)) {
document.removeChild(getElement(dialogId));//删除操作:弹出的div
}
if (getElement(maskId)) {
document.removeChild(getElement(maskId));//删除操作:弹出的不可操作(面具)层
}
//背景置灰
var maskDiv = document.createElement("div");
maskDiv.id = maskId;
maskDiv.style.position = "absolute";
maskDiv.style.zIndex = "1";
maskDiv.style.width = document.body.scrollWidth + "px";
maskDiv.style.height = document.body.scrollHeight + "px";
maskDiv.style.top = "0px";
maskDiv.style.left = "0px";
maskDiv.style.background = "gray";
maskDiv.style.filter = "alpha(opacity=10)";
maskDiv.style.opacity = "0.30";//透明度
document.body.appendChild(maskDiv);//向body之中增加背景层
//Dialog
var dialogDiv = document.createElement("div");
dialogDiv.id = dialogId;
dialogDiv.style.position = "absolute";
dialogDiv.style.zIndex = "9999";
dialogDiv.style.width = "400px";
dialogDiv.style.height = "200px";
dialogDiv.style.top = (parseInt(document.body.scrollHeight) - 200) / 2 + "px"; // 屏幕居中
dialogDiv.style.left = (parseInt(document.body.scrollWidth) - 400) / 2 + "px"; // 屏幕居中
dialogDiv.style.background = "white";
dialogDiv.style.border = "1px solid gray";
dialogDiv.style.padding = "5px";
dialogDiv.innerHTML = "(Dialog Content)";
//Dialog之中的关闭操作:关闭背景层和Dialog层
var closeControlloer = document.createElement("a");//创建一个超链接(做为关闭的触发)
closeControlloer.href = "#";
closeControlloer.innerHTML = "关闭";
closeControlloer.onclick = function() {
document.body.removeChild(getElement(dialogId));//删除diaglog
document.body.removeChild(getElement(maskId));//删除背景层
}
dialogDiv.appendChild(closeControlloer);//dialog之中增加"关闭"操作
document.body.appendChild(dialogDiv);//body之中增加dialog
}
</script>
<a href="#" onclick="openDialog('dialog');">Open Dialog</a>
极乐门资源网 Design By www.ioogu.com
极乐门资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
极乐门资源网 Design By www.ioogu.com
暂无javascript实现的弹出层背景置灰-模拟(easyui dialog)的评论...
更新日志
2025年01月20日
2025年01月20日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]