仿QQ上线提示代码[经典]

html代码:

 

<html>
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>仿QQ消息提示代码</title>
<link href="./img/qq2.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./img/qq2.js"></script>
</head> 
<body  >
  <div id="alex">
    <img src="53935873.jpg" alt="" width="265" height="159" border="0" />
  </div>
</body> 
</html>

 

css代码:

 

#alex {
  top: -200px;
  left: 0px;
  position:absolute;
  z-index: 99999;
  visibility: visible;
  width: 265px;
  height: 159px;
}

 

js代码:

 

window.onload = enetgetMsg;
window.onresize = enetresizeDiv;
window.onerror = function(){}
var enetdivTop,enetdivLeft,enetdivWidth,enetdivHeight,enetdocHeight,enetdocWidth,enetobjTimer,i = 0;
function enetgetMsg()
{
  try{
    enetdivTop = parseInt(document.getElementById("alex").style.top,10)
    enetdivLeft = parseInt(document.getElementById("alex").style.left,10)
    enetdivHeight = parseInt(document.getElementById("alex").offsetHeight,10)
    enetdivWidth = parseInt(document.getElementById("alex").offsetWidth,10)
    enetdocWidth = document.body.clientWidth;
    enetdocHeight = document.body.clientHeight;
    document.getElementById("alex").style.top = parseInt(document.body.scrollTop,10) + enetdocHeight + 10;// enetdivHeight
    document.getElementById("alex").style.left = parseInt(document.body.scrollLeft,10) + enetdocWidth - enetdivWidth
    document.getElementById("alex").style.visibility="visible"
    enetobjTimer = window.setInterval("enetmoveDiv()",10)
  }
  catch(e){}
  }
 
function enetresizeDiv()
{
  i+=1
  if(i>8888) enetcloseDiv()
  try{
    enetdivHeight = parseInt(document.getElementById("alex").offsetHeight,10)
    enetdivWidth = parseInt(document.getElementById("alex").offsetWidth,10)
    enetdocWidth = document.body.clientWidth;
    enetdocHeight = document.body.clientHeight;
    document.getElementById("alex").style.top = enetdocHeight - enetdivHeight + parseInt(document.body.scrollTop,10)
    document.getElementById("alex").style.left = enetdocWidth - enetdivWidth + parseInt(document.body.scrollLeft,10)
  }
  catch(e){}
  }
function enetmoveDiv()
{
  try
  {
    if(parseInt(document.getElementById("alex").style.top,10) <= (enetdocHeight - enetdivHeight + parseInt(document.body.scrollTop,10)))
  {
  window.clearInterval(enetobjTimer)
  enetobjTimer = window.setInterval("enetresizeDiv()",1)
  }
  enetdivTop = parseInt(document.getElementById("alex").style.top,10)
  document.getElementById("alex").style.top = enetdivTop - 1
  }
  catch(e){}
}
function enetcloseDiv()
{
  document.getElementById('alex').style.visibility='hidden';
  if(enetobjTimer) window.clearInterval(enetobjTimer)
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值