特效实现窗口提示,非对话框,非windows.open
实现方法是css+javascript,其实说白了和鼠标点击换图片差不多。将下面代码保存到记事本中,后缀名改为htm。
<SCRIPT language=javascript>
window.onload = getMsg;
window.onresize = resizeDiv;
window.onerror = function(){}
var sdivTop,sdivLeft,sdivWidth,sdivHeight,sdocHeight,sdocWidth,sobjTimer,i = 0;
function getMsg()
{
try{
sdivTop = parseInt(document.getElementById("location").style.top,10)
sdivLeft = parseInt(document.getElementById("location").style.left,10)
sdivHeight = parseInt(document.getElementById("location").offsetHeight,10)
sdivWidth = parseInt(document.getElementById("location").offsetWidth,10)
sdocWidth = document.body.clientWidth - 20;
sdocHeight = document.body.clientHeight;
document.getElementById("location").style.top = parseInt(document.body.scrollTop,10)
+ sdocHeight + 10;// divHeight
document.getElementById("location").style.left = parseInt
(document.body.scrollLeft,10) + sdocWidth - sdivWidth
document.getElementById("location").style.visibility="visible"
sobjTimer = window.setInterval("moveDiv()",10)
}
catch(e){}
}
function resizeDiv()
{
i+=1
if(i>500) closeDiv()
try{
sdivHeight = parseInt(document.getElementById("location").offsetHeight,10)
sdivWidth = parseInt(document.getElementById("location").offsetWidth,10)
sdocWidth = document.body.clientWidth;
sdocHeight = document.body.clientHeight;
document.getElementById("location").style.top = sdocHeight - sdivHeight + parseInt
(document.body.scrollTop,10)
document.getElementById("location").style.left = sdocWidth - sdivWidth + parseInt
(document.body.scrollLeft,10) -20
}
catch(e){}
}
function moveDiv()
{
try
{
if(parseInt(document.getElementById("location").style.top,10) <= (sdocHeight -
sdivHeight + parseInt(document.body.scrollTop,10)))
{
window.clearInterval(sobjTimer)
sobjTimer = window.setInterval("resizeDiv()",1)
}
sdivTop = parseInt(document.getElementById("location").style.top,10)
document.getElementById("location").style.top = sdivTop - 1
}
catch(e){}
}
function closeDiv()
{
document.getElementById('location').style.visibility='hidden';
if(sobjTimer) window.clearInterval(sobjTimer)
}
</SCRIPT>
<DIV id=location style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; FILTER: Alpha
(Opacity=70); VISIBILITY: hidden; BORDER-LEFT: 1px solid; WIDTH: 220px; BORDER-BOTTOM: 1px
solid; POSITION: absolute; TOP: 0px; HEIGHT: 80px; BACKGROUND-COLOR: #E4E8EF">
<TABLE cellSpacing=0 cellPadding=5 width="100%" bgColor=#E4E8EF border=0>
<TBODY><TR><TD>欢迎光临****:</TD></TR><TR>
<TD align=middle
height=90>您还没有注册或登录<BR>请先注册或登录以避免此窗口再次出现<BR><BR><B><A
href="reg.asp">注册</A> <A
href="login.asp">登录</A></B><BR><BR>此视窗10秒后自动关闭
<BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV>
页:
[1]