JS实现始终居中显示的对话框
2012-12-13 17:00
260 查看
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
.Div_Scroll {
position:fixed;
margin:-10px;
visibility:hidden;
background-color:#808080;
opacity:0.6;
z-index:99;
}
.Div_Scroll_Content {
position:relative;
margin-top:20%;
width:inherit;
height:inherit;
}
.Div_AlertWindow {
margin:auto;
width:200px;
height:100px;
background-color:lightblue;
border:5px solid #f00;
}
</style>
<script type="text/javascript">
window.onload = function () {
var alertWindow = $("alertParent");
alertWindow.style.width = window.screen.availWidth + "px";
alertWindow.style.height = window.screen.height + "px";
$("Sure").onclick = function () {
alertWindow.style.visibility = "hidden";
}
}
function ShowAlert() {
var alertWindow = $("alertParent");
alertWindow.style.visibility = "visible";
}
$ = function (id) {
return document.getElementById(id);
}
</script>
</head>
<body>
<div id="alertParent" class="Div_Scroll">
<div class="Div_Scroll_Content">
<div id="AlertWindow" class="Div_AlertWindow">
<input type="button" id="Sure" value="close alert Dialog..." />
</div>
</div>
</div>
<div style="height:1300px; padding-top:200px;" >
<input id="alertButton" type="button" onclick="ShowAlert();" value="Show alert Dialog..."/>
</div>
</body>
</html>
添加遮罩层
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
.Div_Scroll {
position:fixed;
margin:-10px;
visibility:hidden;
background-color:#808080;
opacity:0.6;
z-index:99;
}
.Div_Scroll_Content {
position:relative;
margin-top:20%;
width:inherit;
height:inherit;
}
.Div_AlertWindow {
margin:auto;
width:200px;
height:100px;
background-color:lightblue;
border:5px solid #f00;
}
</style>
<script type="text/javascript">
window.onload = function () {
var alertWindow = $("alertParent");
alertWindow.style.width = window.screen.availWidth + "px";
alertWindow.style.height = window.screen.height + "px";
$("Sure").onclick = function () {
alertWindow.style.visibility = "hidden";
}
}
function ShowAlert() {
var alertWindow = $("alertParent");
alertWindow.style.visibility = "visible";
}
$ = function (id) {
return document.getElementById(id);
}
</script>
</head>
<body>
<div id="alertParent" class="Div_Scroll">
<div class="Div_Scroll_Content">
<div id="AlertWindow" class="Div_AlertWindow">
<input type="button" id="Sure" value="close alert Dialog..." />
</div>
</div>
</div>
<div style="height:1300px; padding-top:200px;" >
<input id="alertButton" type="button" onclick="ShowAlert();" value="Show alert Dialog..."/>
</div>
</body>
</html>
添加遮罩层
相关文章推荐
- Js控制弹窗实现在任意分辨率下居中显示
- Js控制弹窗实现在任意分辨率下居中显示
- JS实现div居中显示的例子
- JS实现图片垂直居中显示小结
- 实现图片始终居中显示于浏览器窗口中心位置
- js实现带关闭按钮始终显示在网页最底部工具条的方法
- 纯js代码实现未知宽高的元素在指定元素中垂直水平居中显示
- JS 实现div 居中显示
- Js控制弹窗实现在任意分辨率下居中显示
- 纯js代码实现未知宽高的元素在指定元素中垂直水平居中显示
- js实现带关闭按钮始终显示在网页最底部工具条的方法
- Qt 关于弹出对话框,实现居中显示!
- JS实现显示带倒影的图片横排居中放大展示特效实例【测试可用】
- Js控制弹窗实现在任意分辨率下居中显示
- 用js实现的一个Flash滚动轮换显示图片代码生成器
- JS实现制作弹出小窗口并获取参数值2(js弹出对话框集合)
- js实现时间显示几天前、几小时前或者几分钟前的方法集锦
- JS将搜索的关键字高亮显示实现代码
- [代码]Delphi实现窗体始终前台显示且获得焦点
- JS实现鼠标经过用户头像显示资料卡的效果,可点击