一个简单的遮罩层效果
2009-06-17 17:27
225 查看
Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>一个简单的遮罩层效果</title>
<script language="javascript">
function openwin() {
if(document.getElementById("mywinOut") == undefined) {
var winOut = document.createElement("div");
winOut.setAttribute("id","mywinOut");
winOut.style.zIndex="98";
winOut.style.left = "0";
winOut.style.top = "0";
winOut.style.width = document.body.scrollWidth;
winOut.style.height = document.body.scrollHeight;
winOut.style.position = "absolute";
winOut.style.background = "#cccccc";
winOut.style.filter="alpha(opacity=60)";
winOut.style.opacity="0.4";
document.body.appendChild(winOut);
var winIn = document.createElement("div");
winIn.setAttribute("id","mywinIn");
winIn.style.zIndex="99";
winIn.style.left = document.body.clientWidth/2 - 200;
winIn.style.top = document.body.scrollTop + 150;
winIn.style.width = 400+"px";
winIn.style.height = 400+"px";
winIn.style.position = "absolute";
winIn.style.background = "#ffffff";
winIn.innerHTML="<center><br><br><br><input type='button' onclick='closewin()' value='关闭'/></center>";
document.body.appendChild(winIn);
} else {
document.getElementById("mywinOut").style.display = "block";
document.getElementById("mywinIn").style.display = "block";
}
}
function closewin() {
document.getElementById("mywinOut").style.display = "none";
document.getElementById("mywinIn").style.display = "none";
}
</script>
</head>
<body>
<center>
<input type="button" onclick="openwin()" value="弹出"/>
<div style="height=1000px"></div>
</center>
</body>
</html>
演示
function openwin() {
if(document.getElementById("mywinOut") == undefined) {
var winOut = document.createElement("div");
winOut.setAttribute("id","mywinOut");
winOut.style.zIndex="98";
winOut.style.left = "0";
winOut.style.top = "0";
winOut.style.width = document.body.scrollWidth;
winOut.style.height = document.body.scrollHeight;
winOut.style.position = "absolute";
winOut.style.background = "#cccccc";
winOut.style.filter="alpha(opacity=60)";
winOut.style.opacity="0.4";
document.body.appendChild(winOut);
var winIn = document.createElement("div");
winIn.setAttribute("id","mywinIn");
winIn.style.zIndex="99";
winIn.style.left = document.body.clientWidth/2 - 200;
winIn.style.top = document.body.scrollTop + 150;
winIn.style.width = 400+"px";
winIn.style.height = 400+"px";
winIn.style.position = "absolute";
winIn.style.background = "#ffffff";
winIn.innerHTML="
";
document.body.appendChild(winIn);
} else {
document.getElementById("mywinOut").style.display = "block";
document.getElementById("mywinIn").style.display = "block";
}
}
function closewin() {
document.getElementById("mywinOut").style.display = "none";
document.getElementById("mywinIn").style.display = "none";
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>一个简单的遮罩层效果</title>
<script language="javascript">
function openwin() {
if(document.getElementById("mywinOut") == undefined) {
var winOut = document.createElement("div");
winOut.setAttribute("id","mywinOut");
winOut.style.zIndex="98";
winOut.style.left = "0";
winOut.style.top = "0";
winOut.style.width = document.body.scrollWidth;
winOut.style.height = document.body.scrollHeight;
winOut.style.position = "absolute";
winOut.style.background = "#cccccc";
winOut.style.filter="alpha(opacity=60)";
winOut.style.opacity="0.4";
document.body.appendChild(winOut);
var winIn = document.createElement("div");
winIn.setAttribute("id","mywinIn");
winIn.style.zIndex="99";
winIn.style.left = document.body.clientWidth/2 - 200;
winIn.style.top = document.body.scrollTop + 150;
winIn.style.width = 400+"px";
winIn.style.height = 400+"px";
winIn.style.position = "absolute";
winIn.style.background = "#ffffff";
winIn.innerHTML="<center><br><br><br><input type='button' onclick='closewin()' value='关闭'/></center>";
document.body.appendChild(winIn);
} else {
document.getElementById("mywinOut").style.display = "block";
document.getElementById("mywinIn").style.display = "block";
}
}
function closewin() {
document.getElementById("mywinOut").style.display = "none";
document.getElementById("mywinIn").style.display = "none";
}
</script>
</head>
<body>
<center>
<input type="button" onclick="openwin()" value="弹出"/>
<div style="height=1000px"></div>
</center>
</body>
</html>
演示
function openwin() {
if(document.getElementById("mywinOut") == undefined) {
var winOut = document.createElement("div");
winOut.setAttribute("id","mywinOut");
winOut.style.zIndex="98";
winOut.style.left = "0";
winOut.style.top = "0";
winOut.style.width = document.body.scrollWidth;
winOut.style.height = document.body.scrollHeight;
winOut.style.position = "absolute";
winOut.style.background = "#cccccc";
winOut.style.filter="alpha(opacity=60)";
winOut.style.opacity="0.4";
document.body.appendChild(winOut);
var winIn = document.createElement("div");
winIn.setAttribute("id","mywinIn");
winIn.style.zIndex="99";
winIn.style.left = document.body.clientWidth/2 - 200;
winIn.style.top = document.body.scrollTop + 150;
winIn.style.width = 400+"px";
winIn.style.height = 400+"px";
winIn.style.position = "absolute";
winIn.style.background = "#ffffff";
winIn.innerHTML="
";
document.body.appendChild(winIn);
} else {
document.getElementById("mywinOut").style.display = "block";
document.getElementById("mywinIn").style.display = "block";
}
}
function closewin() {
document.getElementById("mywinOut").style.display = "none";
document.getElementById("mywinIn").style.display = "none";
}
相关文章推荐
- 一个简单的遮罩层效果
- 代码录播:jQueryMobile 实现一个简单的弹出框效果
- 实现一个简单的手机拍照效果
- 源码推荐(10.10):自定义UITextFields的效果,BabyBluetooth 一个简单易用的蓝牙库
- 使用ListView实现一个简单的学生信息展示效果
- 用jquery做一个简单的图片轮播效果
- 一个简单的JS模拟屏保效果
- jQuery框架开发一个最简单的幻灯效果
- 一个简单的手风琴效果
- 用CSS实现一个简单的幻灯片效果页面
- Unity3d 一个简单的玻璃效果实现!
- 简单的做了一个评分控件,其实还算不上控件,只是用javascript做了一个效果,可以直接放在你的程序中使用。
- 请写一个简单的幻灯效果页面。如果不使用JS来完成,可以加分。
- 一个简单的实现tab效果的demo
- 一个案例教你简单地玩转ViewPager(三)之带指示点的图片自动轮播效果
- 一个简单的行拖动效果
- 一个简单的滑动门效果
- 利用jQuery实现一个简单的表格上下翻页效果
- 一个简单的Viewport效果
- Bootboxjs是一个简单的js库,简单快捷帮你制作一个Bootstrap的弹出框效果。