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)}
相关资源:类似于QQ弹出提醒代码