爱你网
爱你网的公告








一个不错的P2P软件,里面肯定有你要的资源

我的爱你网,讨论.Net


最近评论
zq32206124:英文看不懂啊
zq32206124:英文看不懂啊
jing_cai:谢谢你的无私奉献!
heaven_hao:希望能把格式整理一下,有内容也看不清楚
snowwolf1987:不知道为什么,在Dreamver中
left div with可设为20%,Right div with可设为80%,但是为什么在asp.net2.0中则左右之和要小于100%,否则显示不正常
文章分类
收藏
相册
Csdn专用
个人专用
XML相关资料
XML Server与XML-enabled Web Server介绍
xmlhttp发送 xml 例子详解
在Asp.net里显示XML格式内容.
树的资料
asp.net中的treeview 怎么用
数据库连接
CSDN数据库连接大全
DSN方式连接数据库
杂类
100分问一个突然出现的Cookie问题,关于添加/删除Cookie的。
c#存取图片 (RSS)
我的主页(RSS)
高效.TEXTBLOG技巧终结篇
存档
软件项目交易
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
订阅到BlogLines
订阅到Yahoo
订阅到GouGou
订阅到飞鸽
订阅到Rojo
订阅到newsgator
订阅到netvibes

原创 Js + Css的msn式的popup提示窗口的实现收藏

新一篇: 捕获window.close()事件写自己的方法 | 旧一篇: FireFox中location跳转问题

Msn的提示窗口非常经典,所以我们也做一个javascript实现一下,给大家逗乐用。   闲话不多说,Javascript代码如下:

只有javascript代码还是不够的,我们还需要css来定义样式:

DIV#eMsg{}{     background-color: #c9d3f3;     border-left: #a6b4cf 1px solid;     border-right: #455690 1px solid;     border-top: #a6b4cf 1px solid;     border-bottom: #455690 1px solid;     visibility: hidden;     width: 199px;     height: 97px;     position: absolute;     z-index: 99999;     left: 0px; } DIV#eMsg DIV.eMsgInner {}{     border-top: #ffffff 1px solid;     border-left: #ffffff 1px solid;     background-color:#cfdef4;     height:96px;     width:198px; } DIV#eMsgInner DIV.head{}{width:197px} DIV.headLeft{}{width:30px;float:left;} DIV.headMiddle{}{     width:150px;     text-align:center;     float:left;     padding-top:2px;     color:green;     font-weight:bold } DIV.headRight{}{width:16;float:left;} DIV.headRight IMG{}{     width:13px;     height:13px;     border:0px;     cursor:hand;     margin:2px; } DIV.body{}{     height:82px;     clear:both;     border-right: #b9c9ef 1px solid;     padding: 13px;      padding-top: 1px;     border-top: #728eb8 1px solid;     border-left: #728eb8 1px solid;     color: #1f336b;     word-break: break-all;     border-bottom: #b9c9ef 1px solid; } DIV.light{}{text-align:center;padding:5px 20px} DIV.content{}{text-align:center;height:65px;padding-top:10px}

以上是所有的实现代码,我们在使用时还需要做以下两步 1.我们需要在body标签的前面加上加载message的语句 document.write('<sc' + 'ript>' + 'eMsg.createInstance("月牙儿工作室提示","<div align=left>新增加了邮箱登录和地图查询两个模块欢迎您添加使用。</div>");'); document.write('</s') document.write('cript>'); 2.还需要在body的onload事件中添加eMsg.onLoad();   这样就大功告成了,大家可以从我的博客中看到效果的。

有兴趣的朋友可以把它封装成.net控件呀。

/**//*eMsg*/ var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,i = 0; var eMsg = new Object(); eMsg.lightSrc = '../image/message/light.gif'; eMsg.closeSrc = '../image/message/msgclose.gif'; eMsg.id = 'eMsg'; eMsg.obj = function(){return document.getElementById(eMsg.id);};

eMsg.onLoad = function(){     try{         divTop = parseInt(eMsg.obj().style.top,10);         divLeft = parseInt(eMsg.obj().style.left,10);         divHeight = parseInt(eMsg.obj().offsetHeight,10);         divWidth = parseInt(eMsg.obj().offsetWidth,10);         docWidth = document.body.clientWidth;         docHeight = document.body.clientHeight;         eMsg.obj().style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;         eMsg.obj().style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth;         eMsg.obj().style.visibility="visible";         eMsg.timer = window.setInterval(eMsg.move,1);         hp.skin.onBeforChange = function(){             if(eMsg.obj())eMsg.obj().parentNode.removeChild(eMsg.obj());         };     }     catch(e){} }; eMsg.onResize = function(){     i+=1;     if(i>1000) eMsg.close();     try{         divHeight = parseInt(eMsg.obj().offsetHeight,10);         divWidth = parseInt(eMsg.obj().offsetWidth,10);         docWidth = document.body.clientWidth;         docHeight = document.body.clientHeight;         eMsg.obj().style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10);         eMsg.obj().style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10);     }     catch(e){} }; eMsg.move = function(){     try     {         if(parseInt(eMsg.obj().style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))         {             window.clearInterval(eMsg.timer);             eMsg.timer = window.setInterval(eMsg.onResize,1);         }         divTop = parseInt(eMsg.obj().style.top,10);         eMsg.obj().style.top = divTop - 1;     }     catch(e){} }; eMsg.close = function(){     eMsg.obj().parentNode.removeChild(eMsg.obj());     if(eMsg.timer) window.clearInterval(eMsg.timer); }; eMsg.createInstance = function(titleHtml,bodyHtml){     if(!titleHtml || !bodyHtml)throw '必须为titleHtml指定值,必须为bodyHtml指定值。';     var odiv = document.createElement('DIV');     odiv.id = eMsg.id;     odiv.innerHTML = '<div class="eMsgInner">'     + '<div class="head">'         + '<div class="headLeft"><img src="http://www.pushad.com/Info/space.gif" height="1" width="1"/></div>'         + '<div class="headMiddle">' + titleHtml + '</div>'         + '<div class="headRight"><img src="' + eMsg.closeSrc  + '" onclick="eMsg.close()" align="absmiddle"/></div>'     + '</div>'     + '<div class="body" oncontextmenu="eMsg.close();return false;" title="右键关闭">'         + '<div class="light"><IMG src="' + eMsg.lightSrc + '"></div>'         + '<div class="content">'         + bodyHtml            + '</div>'     + '</div>'     + '</div>';     document.body.appendChild(odiv); };

window.onresize = eMsg.onResize;

发表于 @ 2008年07月03日 15:19:30|评论(loading...)|收藏

新一篇: 捕获window.close()事件写自己的方法 | 旧一篇: FireFox中location跳转问题

评论:没有评论。

发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © 爱你网