[转载]制作从屏幕右下方逐渐弹出的消息框

本文介绍了一种模仿MSN右下角弹出广告的方法,并附带了关闭按钮功能。通过JavaScript实现了广告窗口从屏幕底部逐渐上升的效果,并确保其始终位于浏览器窗口的右下角。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

None.gif<html>
None.gif
<head>
None.gif
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
None.gif
<title>完美仿MSN右下角弹出广告附带关闭按钮</title>
None.gif
</head>
ExpandedBlockStart.gifContractedBlock.gif
<Script language="JavaScript">dot.gif
InBlock.gif
<!--
InBlock.gifwindow.onload 
= getMsg;
InBlock.gifwindow.onresize 
= resizeDiv;
ExpandedSubBlockStart.gifContractedSubBlock.gifwindow.onerror 
= function()dot.gif{}
InBlock.gif
//短信提示使用(asilas添加)
InBlock.gif
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
InBlock.gif
function getMsg()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif
trydot.gif{
InBlock.gifdivTop 
= parseInt(document.getElementById("eMeng").style.top,10)
InBlock.gifdivLeft 
= parseInt(document.getElementById("eMeng").style.left,10)
InBlock.gifdivHeight 
= parseInt(document.getElementById("eMeng").offsetHeight,10)
InBlock.gifdivWidth 
= parseInt(document.getElementById("eMeng").offsetWidth,10)
InBlock.gifdocWidth 
= document.body.clientWidth;
InBlock.gifdocHeight 
= document.body.clientHeight;
InBlock.gifalert('divTop  '
+divTop)
InBlock.gifalert('divHeight  '
+divHeight)
InBlock.gifalert('docHeight  '
+docHeight)
InBlock.gifdocument.getElementById(
"eMeng").style.top = parseInt(document.body.scrollTop,10+ docHeight + 10;//  divHeight
InBlock.gif
document.getElementById("eMeng").style.left = parseInt(document.body.scrollLeft,10+ docWidth - divWidth
InBlock.gifdocument.getElementById(
"eMeng").style.visibility="visible"
InBlock.gifobjTimer 
= window.setInterval("moveDiv()",10)
ExpandedSubBlockEnd.gif}

ExpandedSubBlockStart.gifContractedSubBlock.gif
catch(e)dot.gif{}
ExpandedSubBlockEnd.gif}

InBlock.gif
InBlock.gif
function resizeDiv()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gifi
+=1
InBlock.gif
if(i>300) closeDiv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
ExpandedSubBlockStart.gifContractedSubBlock.gif
trydot.gif{
InBlock.gifdivHeight 
= parseInt(document.getElementById("eMeng").offsetHeight,10)
InBlock.gifdivWidth 
= parseInt(document.getElementById("eMeng").offsetWidth,10)
InBlock.gifdocWidth 
= document.body.clientWidth;
InBlock.gifdocHeight 
= document.body.clientHeight;
InBlock.gif
InBlock.gifdocument.getElementById(
"eMeng").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10)
InBlock.gifdocument.getElementById(
"eMeng").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10)
ExpandedSubBlockEnd.gif}

ExpandedSubBlockStart.gifContractedSubBlock.gif
catch(e)dot.gif{}
ExpandedSubBlockEnd.gif}

InBlock.gif
InBlock.gif
function moveDiv()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
try
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
//alert('document.getElementById("eMeng").style.top  '+document.getElementById("eMeng").style.top)
InBlock.gif
        if(parseInt(document.getElementById("eMeng").style.top,10<= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif        
InBlock.gif        window.clearInterval(objTimer)
InBlock.gif        
//objTimer = window.setInterval("resizeDiv()",1)
ExpandedSubBlockEnd.gif
        }

InBlock.gif        divTop 
= parseInt(document.getElementById("eMeng").style.top,10)
InBlock.gif        document.getElementById(
"eMeng").style.top = divTop - 1
InBlock.gif        
//alert('scrollTop   '+parseInt(document.body.scrollTop,10))
ExpandedSubBlockEnd.gif
    }

ExpandedSubBlockStart.gifContractedSubBlock.gif    
catch(e)dot.gif{}
ExpandedSubBlockEnd.gif}

InBlock.gif
function closeDiv()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gifdocument.getElementById('eMeng').style.visibility
='hidden';
InBlock.gif
if(objTimer) window.clearInterval(objTimer)
ExpandedSubBlockEnd.gif}

ExpandedBlockEnd.gif
-->
None.gif
</Script>
None.gif
None.gif
<!--温馨提示代码开始-->
None.gif
None.gif
<DIV id=eMeng style="BORDER-RIGHT: #455690 1px solid; BORDER-TOP: #a6b4cf 1px solid; Z-INDEX:99999; LEFT: 0px; VISIBILITY: hidden; BORDER-LEFT: #a6b4cf 1px solid; WIDTH: 180px; BORDER-BOTTOM: #455690 1px solid; POSITION: absolute; TOP: 0px; HEIGHT: 116px; BACKGROUND-COLOR: #c9d3f3">
None.gif
<TABLE style="BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid" cellSpacing=0 cellPadding=0 width="100%" bgColor=#AFDCF3 border=0>
None.gif
<TBODY>
None.gif  
<TR bgColor=#6699cc>
None.gif   
<TD style="font-size: 12px; background-image: url('msgTopBg.gif'); color: #0f2c8c" width=30 height=24></TD>
None.gif   
<TD style="font-weight: normal; font-size: 12px; background-image: url('msgTopBg.gif'); color: #ffffff; padding-left: 4px; padding-top: 4px" vAlign=center width="100%"> 网站温馨提示:</TD>
None.gif   
<TD style="background-image: url('msgTopBg.gif'); padding-right: 2px; padding-top: 2px" vAlign=center align=right width=19><span title=关闭 style="CURSOR: hand;color:white;font-size:12px;font-weight:bold;margin-right:4px;" onclick=closeDiv() >×</span><!--<IMG title=关闭 style="CURSOR: hand" onclick=closeDiv() hspace=3 src="msgClose.jpg">--></TD>
None.gif  
</TR>
None.gif  
<TR>
None.gif   
<TD style="background-image: url('http://pic.tianyaclub.com/images/windty_bg.jpg'); padding-right: 1px; padding-bottom: 1px" colSpan=3 height=90>
None.gif    
<DIV style="BORDER-RIGHT: #b9c9ef 1px solid; PADDING-RIGHT: 13px; BORDER-TOP: #728eb8 1px solid; PADDING-LEFT: 13px; FONT-SIZE: 12px; PADDING-BOTTOM: 13px; BORDER-LEFT: #728eb8 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 18px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%">先飞电脑技术网全新改版,免费精品网络资源,你用了吗?<BR>
None.gif    
<DIV align=center style="word-break:break-all"><!--<a href="http://pic.tianyaclub.com/default.asp?idWriter=0&Key=0" target="_blank">--><href="http://www.xfbbs.com" target="_blank">
None.gif    
<font color=#FF0000>进入网站浏览</font></a></DIV>
None.gif
None.gif    
</DIV>
None.gif   
</TD>
None.gif  
</TR>
None.gif
</TBODY>
None.gif
</TABLE>
None.gif
</DIV>
None.gif
<!--温馨提示代码结束-->
None.gif
</html> 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值