领先的中文IT技术网站    IT技术从现在起飞

飞诺旗下: 技术社区 | 在线电子书 | 在线试题 | 资源下载 | 飞诺搜索 | 技术博客
用户名: 密   码:
   飞诺网 加入收藏
飞诺网 网页设计 新闻频道 开发频道 系统频道 服务器 网络频道 网络安全 Java频道 C/C++ PHP开发 电子书 资源下载 社 区 博 客 在线试题
网页设计 FrontPage Dreamweaver html Javascript css 网页制作技巧 网页特效 色彩原理 设计理念 web技术文章
编程开发 JAVA C/C++ C++ VC C语言 VB C# Delphi Foxpro 汇编 shell编程 游戏开发 软件工程师 WEB开发 PHP ASP Asp.net JSP AJAX CGI JavaScript HTML CSS 数据库 MSSQL Mysql Oracle Access Sybase DB2 sql2005 Office Word Excel Powerpoint Wps 认证考试 二级C语言 三级网络 程序员 网络工程师 思科认证

您当前的位置:飞诺网 >>  网页设计 >> web技术文章

弹出窗口悬浮,背景页面变灰,类似网易邮箱的半透明信息提示效果

www.firnow.com    时间 : 2010-08-13  作者:佚名   编辑:善意的谎言 点击:   [ 评论 ]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>类似网易邮箱的半透明信息提示效果</title>
<meta name="author" content="年华@Master8.NET" />
<style>
body { background-color:#FFFFFF; margin:0;}
li,td,div,body {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #333333; }
</style>
</head>
<body>
<script type="text/javascript">//必须body中引用
var width=300;
var height=200;
var bgcolor="#EEEEEE";//半透明窗口背景色DivMid
var trans=90;
var body = document.body;
var bodyWidth = parseInt((body.scrollWidth<body.clientWidth)?body.clientWidth:body.scrollWidth);
var bodyHeight = parseInt((body.scrollHeight<body.clientHeight)?body.clientHeight:body.scrollHeight);
var clientWidth=body.clientWidth;
var clientHeight=body.clientHeight;
//开始创建DivTop 最上信息层
var DivTop = document.createElement("div");
with(DivTop.style)
{
display = "none";
zIndex = 3;
position = "absolute";
border = "0px";
}
DivTop.id = "Div3"; body.appendChild(DivTop);
DivTop.innerHTML = "<table cellspacing=\"0\"

cellpadding=\"0\" style=\"width:"+width+"px;border:#0051E5 1px solid;background:#FFFFFF;\">

<tr><td style=\"background:#0051E5;color:#FFFFFF;font-size:13px;height:18px;\"><span style=\"float:right\"><a href=\"javascript:Close();\" style=\"color:#FFFFFF;text-decoration:none;background:#CC4332;display:block;padding:1px;height:14px;width:14px;font-size:12px;overflow:hidden;\">×</a></span> 信 息 提 示</td></tr><tr><td style=\"line-height:180%;padding:2px;\"> 类似网易邮箱的半透明信息提示效果<br /> <a href=\"http://master8.net\">Master8.NET</a></td></tr></table>";

//开始创建DivMid 中间半透明层
var DivMid = document.createElement("div");
with(DivMid.style)
{
display = "none";
zIndex = 2;
position = "absolute";
height = "100%";
width = "100%";
top = 0;
left = 0;
border = "0px";
backgroundColor = bgcolor;
}
DivMid.id = "Div2";
body.appendChild(DivMid);

function $(Id) { return document.getElementById(Id); }
function isIE()
{
return (document.all && window.ActiveXObject && !window.opera) ? true : false;
}

function center(win)//将主窗口置于网页正中
{
var s = parseInt(body.scrollTop + clientHeight/2 - height/2);
win.style.top = (s<body.scrollHeight-height)?s:body.scrollHeight;
var s = parseInt(body.scrollLeft + clientWidth/2 - width/2);
win.style.left = (s<body.scrollWidth-width)?s:body.scrollWidth;
}

function Open(){

with(body.style)//完全锁定背景层
{
width = clientWidth;
height = clientHeight;
overflow = "hidden";
}
with($(''Div2'').style)
{
width = bodyWidth;
height = bodyHeight;
overflow = "hidden";
display = "";
if (isIE()){
filter = " Alpha(Opacity="+trans+")";
}else{
opacity = trans/100;
}

}
with($(''Div3'').style)
{
display = "";
}
center($(''Div3''));

}

function Close(){
with(body.style)
{
width = bodyWidth;
height = bodyHeight;
overflow = "auto";
}
with($(''Div2'').style)
{
display = "none";
}
with($(''Div3'').style)
{
display = "none";
}

}
Open();
</script>
<p align="center"><a href="javascript:Open()">Click To Open</a></p>
<p align="center"><a href="javascript:Open()">Click To Open</a></p></body>
</html>

如果图片或页面不能正常显示请点击这里
web技术文章推荐文章

文章评论

BBS社区热贴