当前位置: 首页 > article >正文

用JavaScript在网页右下角弹出窗口

  • 在右下角弹出窗口,常用于广告代码,或一些大网站的用户信息提示,并且会自动隐藏,可以设置时间间隔,弹出窗口的位置和大小,当然,窗口内容全靠你定了,将JS保存为JS文件,方便你调用。  

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网页右下角的信息框</title>
</head>
<style type="text/css">
#winpop { width:200px; height:0px; position:absolute; right:0; bottom:0; border:1px solid #666; margin:0; padding:1px; overflow:hidden; display:none;}
#winpop .title { width:100%; height:22px; line-height:20px; background:#FFCC00; font-weight:bold; text-align:center; font-size:12px;}
#winpop .con { width:100%; height:90px; line-height:80px; font-weight:bold; font-size:12px; color:#FF0000; text-decoration:underline; text-align:center}
#silu { font-size:12px; color:#666; position:absolute; right:0; text-align:right; text-decoration:underline; line-height:22px;}
.close { position:absolute; right:4px; top:-1px; color:#FFF; cursor:pointer}
</style>
<script type="text/javascript">
function tips_pop(){
  var MsgPop=document.getElementById("winpop");
  var popH=parseInt(MsgPop.style.height);//将对象的高度转化为数字
   if (popH==0){
   MsgPop.style.display="block";//显示隐藏的窗口
  show=setInterval("changeH('up')",2);
   }
  else { 
   hide=setInterval("changeH('down')",2);
  }
}
function changeH(str) {
 var MsgPop=document.getElementById("winpop");
 var popH=parseInt(MsgPop.style.height);
 if(str=="up"){
  if (popH<=100){
  MsgPop.style.height=(popH+4).toString()+"px";
  }
  else{  
  clearInterval(show);
  }
 }
 if(str=="down"){ 
  if (popH>=4){  
  MsgPop.style.height=(popH-4).toString()+"px";
  }
  else{ 
  clearInterval(hide);   
  MsgPop.style.display="none";  //隐藏DIV
  }
 }
}
window.οnlοad=function(){//加载
document.getElementById('winpop').style.height='0px';
setTimeout("tips_pop()",800);//3秒后调用tips_pop()这个函数
}
</script>
<body>
<div id="silu">
<button οnclick="tips_pop()">3秒后会在右下角自动弹出窗口,如果没有弹出请点击这个按钮</button>
</div>
<div id="winpop">
<div class="title">您有新的短消息!<span class="close" οnclick="tips_pop()">X</span></div>
    <div class="con">1条未读信息(</div>
</div>
</body>
</html>
http://www.lryc.cn/news/2418826.html

相关文章:

  • C#动态循环生成控件(附源码)
  • 泽西岛Java教程
  • vrml场景实例代码_【免费毕设】JAVA3D的网络三维技术的设计与实现(源代码+论文+说明)...
  • 整人BAT\VBS代码 自创
  • 网络安全初学者必备的60个工具,零基础入门到精通,收藏这一篇就够了
  • FileUpload实现多文件上传与下载
  • 电脑xp系统坏了,如何处理
  • html 设置min height,CSS中min-height使用技巧
  • 教育界常用网站汇总
  • 常用搜索引擎搜索串
  • ISA Server是什么
  • 中移动详解Mobile Market运作流程
  • 计算机毕业设计PHP短视频管理小程序(源码+程序+uni+lw+部署)
  • 《数据库系统概念》——关系数据库
  • Postgresql B-tree索引
  • 【汇编】80x86指令系统
  • python爬取电影天堂的下载链接
  • 推荐几个好用的网站导航
  • 博弈论、竞价机制和AI
  • 手把手教您:iOS 6.1~6.12 完美越狱教程
  • Executors一篇就够
  • Windows 网络编程
  • 各种TCP端口详细说明中文版
  • 硬件工程师需要学习哪些知识
  • Linux下7.3虚拟机的完整封装
  • 马云语录——经典!
  • 戴尔笔记本开机logo进度条时间长的解决办法
  • 总结 vb与数据库的连接方法
  • 李开复--生命是最严厉的导师
  • 虐杀原形2闪退、prototype2打开闪退,无法运行解决办法