<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
#divDisplay1{display:none; position:absolute; width:300px; height:200px; background-color:#FF0; z-index:999;}
#divDisplay{ display:none; position:absolute; top:50%; left:50%; margin:-150px; width:300px; height:200px; background-color:#FF0; z-index:999;}
</style><script language="javascript" >var isIe=(document.all)?true:false;//判断是不是IE浏览器
//alert(isIe);
//设置select的可见状态//弹出方法
function showDivBox() //创建遮罩层
{
var bWidth=parseInt(document.documentElement.scrollWidth); //得到窗口的宽度;
var bHeight=parseInt(document.documentElement.clientHeight); //得到窗口的高度;
if(isIe){
// setSelectState('hidden');
}
var back=document.createElement("div");
back.id="backdiv";
var styleStr="top:0px;left:0px;position:absolute;z-index:100;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;";
styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;";
back.style.cssText=styleStr;
document.body.appendChild(back);
showBackground(back,50);
document.getElementById('divDisplay').style.display='block';
tem1=document.getElementById('backdiv');
tem2=document.getElementById('divDispaly');
}
//让背景渐渐变暗
function showBackground(obj,endInt)
{
if(isIe){
obj.filters.alpha.opacity+=1;
if(obj.filters.alpha.opacity<endInt)
{
setTimeout(function(){showBackground(obj,endInt)},5);
}
}else{
var al=parseFloat(obj.style.opacity);al+=0.01;
obj.style.opacity=al;
if(al<(endInt/100)){
setTimeout(function(){showBackground(obj,endInt)},5);
}
}
}
function removeLayer()
{
document.getElementById('divDisplay').style.display='none';
document.getElementById('backdiv').style.display='none';
//alert("ok");
}
</script>
<title>弹出层</title>
</head>
<body>
<div id="divDisplay"><a href="#" onclick="removeLayer()"> 确定</a> <a href="#">取消</a></div>
<a href="#" onclick="showDivBox()">测试</a>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
#divDisplay1{display:none; position:absolute; width:300px; height:200px; background-color:#FF0; z-index:999;}
#divDisplay{ display:none; position:absolute; top:50%; left:50%; margin:-150px; width:300px; height:200px; background-color:#FF0; z-index:999;}
</style><script language="javascript" >var isIe=(document.all)?true:false;//判断是不是IE浏览器
//alert(isIe);
//设置select的可见状态//弹出方法
function showDivBox() //创建遮罩层
{
var bWidth=parseInt(document.documentElement.scrollWidth); //得到窗口的宽度;
var bHeight=parseInt(document.documentElement.clientHeight); //得到窗口的高度;
if(isIe){
// setSelectState('hidden');
}
var back=document.createElement("div");
back.id="backdiv";
var styleStr="top:0px;left:0px;position:absolute;z-index:100;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;";
styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;";
back.style.cssText=styleStr;
document.body.appendChild(back);
showBackground(back,50);
document.getElementById('divDisplay').style.display='block';
tem1=document.getElementById('backdiv');
tem2=document.getElementById('divDispaly');
}
//让背景渐渐变暗
function showBackground(obj,endInt)
{
if(isIe){
obj.filters.alpha.opacity+=1;
if(obj.filters.alpha.opacity<endInt)
{
setTimeout(function(){showBackground(obj,endInt)},5);
}
}else{
var al=parseFloat(obj.style.opacity);al+=0.01;
obj.style.opacity=al;
if(al<(endInt/100)){
setTimeout(function(){showBackground(obj,endInt)},5);
}
}
}
function removeLayer()
{
document.getElementById('divDisplay').style.display='none';
document.getElementById('backdiv').style.display='none';
//alert("ok");
}
</script>
<title>弹出层</title>
</head>
<body>
<div id="divDisplay"><a href="#" onclick="removeLayer()"> 确定</a> <a href="#">取消</a></div>
<a href="#" onclick="showDivBox()">测试</a>
</body>
</html>
解决方案 »
- js 函数怎么实现这样的功能
- 请精通或开过政府举报网站的朋友进来一下。
- 求一个时间递归的算法。。
- 用JS生成一个层
- ☆★☆★像豆瓣网上传动态头像后却变成了静态不会动的,请问是怎么实现的呢?
- 如何将层定位到一个链接的右下角?
- javascript 中用fso访问文件时,如何实现遍历文件和文件啊?急求
- 为什么这样不能document.getElementById("form1").getElementsByName("a");
- 「请教」查找父项之前,先折叠文本范围
- 请教一段javascript代码?
- getelementsbyname 返回值是数组?
- 谁研究过ExtjsHotel(酒店管理系统)的代码???
// 弹出方法
function showDivBox() // 创建遮罩层
{ var bWidth = parseInt(document.documentElement.scrollWidth); // 得到窗口的宽度;
var bHeight = parseInt(document.documentElement.clientHeight); // 得到窗口的高度;
if (isIe)
{
// setSelectState('hidden');
}
var styleStr = "top:0px;left:0px;position:absolute;z-index:100;background:#666;width:"
+ bWidth + "px;height:" + bHeight + "px;";
styleStr += (isIe) ? "filter:alpha(opacity=0);" : "opacity:0;";
var back = document.getElementById('backdiv'); //第二次再打开的时候 不能新建div了 直接拿那个backdiv操作
if (back == null)
{
back = document.createElement("div");
back.id = "backdiv";
back.style.cssText = styleStr;
document.body.appendChild(back);
}
else
{
back.style.cssText = styleStr; //还原样式
}
showBackground(back, 50);
document.getElementById('divDisplay').style.display = 'block';
tem1 = document.getElementById('backdiv');
tem2 = document.getElementById('divDispaly');
}