您的位置:首页 > 其它

自动弹出窗口,并定时关闭

2006-09-27 18:33 411 查看
弹出的消息代码:

<SCRIPT language=JavaScript src="js/popup.js"></SCRIPT>
<DIV id=windlocation style="LEFT: 50px; VISIBILITY: hidden; WIDTH: 1px; POSITION: absolute; TOP: 100px; HEIGHT: 1px">
<TABLE style="BORDER-RIGHT: 1px outset; BORDER-TOP: 1px outset; BORDER-LEFT: 1px outset; BORDER-BOTTOM: 1px outset"height=220 width=300 bgColor=#FFF9EE>
<TBODY>
<TR>
<TD>
<TABLE class=f_one style="BORDER-RIGHT: 1px inset; BORDER-TOP: 1px inset; BORDER-LEFT: 1px inset; BORDER-BOTTOM: 1px inset" height=200 width=280 align=center bgColor=#ffffff>
<TBODY>
<TR>
<TD vAlign=center align=middle><BR><BR><img src="images/iconMailBlue_16x16.gif" width="16" height="16"> <strong><span style="font-size:13px;">您有新的消息请注意查收</span><BR><BR>
<a href="msg_receive.asp"><strong>您有 <font color="#FF0000"><%=msgtotal%></font> 条留言</strong></a> </strong>
<P>(此视窗将于 5 秒后自动关闭)
</P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
</DIV>

popup.js 包含的JS文件

timePopup=5;
var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
adCount=0;
function initPopup(){
if(!ns && !ie && !w3){
return;
}
if(ie){
adDiv=eval('document.all.windlocation.style');
}else if(ns){
adDiv=eval('document.layers["windlocation"]');
}else if(w3){
adDiv=eval('document.getElementById("windlocation").style');
}
if (ie||w3){
adDiv.visibility="visible";
}else{
adDiv.visibility ="show";
}
showPopup();
}
function showPopup(){
if(adCount<timePopup*10){
adCount+=1;
if (ie){
documentWidth =document.body.offsetWidth/2+document.body.scrollLeft-20;
documentHeight =document.body.offsetHeight/2+document.body.scrollTop-20;
} else if (ns){
documentWidth=window.innerWidth/2+window.pageXOffset-20;
documentHeight=window.innerHeight/2+window.pageYOffset-20;
} else if (w3){
documentWidth=self.innerWidth/2+window.pageXOffset-20;
documentHeight=self.innerHeight/2+window.pageYOffset-20;
}
adDiv.left=documentWidth-250;
adDiv.top =documentHeight-150;
setTimeout("showPopup()",100);
}else{
closePopup();
}
}
function closePopup(){
if (ie||w3){
adDiv.display="none";
}else{
adDiv.visibility ="hide";
}
}
onload=initPopup;

把弹出代码放在想执行的文件中就可以了.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: