网站右下角弹窗JS。

网站右下脚JS弹窗。。。 这个JS怎么写? 在页面上直接<script type="text/javascript"> 引用就可以弹出的。

http://hi.baidu.com/shuanglinwanyu/blog/item/1f1c28dc706666a7cd1166eb.html <!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">body { background:#333333;}#winpop {
width:200px;
height:0px;
position:absolute;
right:0px;
bottom:0px;
border:1px solid #999999;
margin:0;
padding:1px;
overflow:hidden;
display:none;
background:#FFFFFF;
}#winpop .title {
width:100%;
height:20px;
line-height:20px;
background:#FFCC00;
font-weight:bold;
text-align:center;
font-size:12px;
}#winpop .con {
width:100%;
height:80px;
line-height:80px;
font-weight:bold;
ont-size:12px;
color:#FF0000;
text-decoration:underline;
text-align:center;
}.close {
position:absolute;
right:4px;
top:-1px;
color:#FFFFFF;
cursor:pointer;
}</style><script type="text/javascript">function tips_pop(){var MsgPop=document.getElementById("winpop");//获取窗口这个对象,即ID为winpop的对象

var popH=parseInt(MsgPop.style.height);//用parseInt将对象的高度转化为数字,以方便下面比较;

if (popH==0){//如果窗口的高度是0,与末尾的初始化高度相互对应;

MsgPop.style.display="block";//那么将隐藏的窗口显示出来

show=setInterval("changeH('up')",2);//开始以每0.002秒调用函数changeH("up"),即每0.002秒向上移动一次
}

else { //否则

hide=setInterval("changeH('down')",2);//开始以每0.002秒调用函数changeH("down"),即每0.002秒向下移动一次

}
}function changeH(str) {var MsgPop=document.getElementById("winpop");var popH=parseInt(MsgPop.style.height);

if(str=="up"){ //如果这个参数是UP

if (popH<=100){ //如果转化为数值的高度小于等于100

MsgPop.style.height=(popH+4).toString()+"px";//高度增加4个象素;

}

else{

clearInterval(show);//否则就取消这个函数调用,意思就是如果高度超过100象度了,就不再增长了;

}
}

if(str=="down"){

if (popH>=4){ //如果这个参数是down

MsgPop.style.height=(popH-4).toString()+"px";//那么窗口的高度减少4个象素

}

else{ //否则

clearInterval(hide); //否则就取消这个函数调用,意思就是如果高度小于4个象度的时候,就不再减了

MsgPop.style.display="none"; //因为窗口有边框,所以还是可以看见1~2象素没缩进去,这时候就把DIV隐藏掉

}

}
}
window.onload=function(){ //加载

document.getElementById('winpop').style.height='0px';//初始化高度为0px,

setTimeout("tips_pop()",800); //3秒后调用tips_pop()这个函数
}</script><body><div id="silu"><高手请忽略本文-------------------------><h2>首先,我们需要知道理解一下动画的概念,动画就是随着时间的变化产生位置移动</h2>

在JS中用到的函数是setInterval(),具体的使用请去看javascript相关文档

<h3>下面是下本例子的思路:</h3>

这个时候我们会去猜想:

如果没有窗口,就让它出来.如果窗口存在,那么就让它消失.

对,就是if..else..条件判断了~~

那么窗口消失的状态是什么呢?

就是height=0.

height=0的时候就是隐藏

height=100px的时候就是显示

所以利用高度的变化就是效果实现的方法.

而且是随着时间一点点的位置变化造成动画了效果
<button onclick="tips_pop()">测试按钮</button></div><div id="winpop"><div class="title">您有新的消息<span class="close" onclick="tips_pop()">X</span></div> <div class="con">未读信息(1)</div>
</div></body></html>
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-07-24
<script type="text/javascript"> function setCookie(name, value, expire) { window.document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString())); } function getCookie(Name) { var search = Name + "="; if (window.document.cookie.length > 0) { // if there are any cookies offset = window.document.cookie.indexOf(search); if (offset != -1) { // if cookie exists offset += search.length; // set index of beginning of value end = window.document.cookie.indexOf(";", offset) // set index of end of cookie value if (end == -1) end = window.document.cookie.length; return unescape(window.document.cookie.substring(offset, end)); } } return null; } function register(name) { var today = new Date(); var expires = new Date(); expires.setTime(today.getTime() + 1000*60*60*24); setCookie("k686", name, expires); } var exitURL=" "; //广告地址 function openWin() { var c = getCookie("k686"); if (c != null) { return; } register("9abc"); var featureStr="''"; featureStr="'top=0,left=0,width=800,height=600,toolbar=yes, menubar=no, scrollbars=no, resizable=no, location=no, status=no,center:no'"; self.focus(); var ExitWindow = window.open(exitURL); ExitWindow.focus(); } openWin(); window.focus(); </script>
第2个回答  2013-07-24
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ">
<html xmlns=" ">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>右下角弹窗</title>
<script language="JavaScript" type="text/javascript">
function $(obj){
return document.getElementById(obj);
}
function pop(obj){
var h = parseInt($("popDiv").currentStyle.height);
$("popDiv").style.height = (h + obj) + "px";
if(parseInt($("popDiv").style.height) < 2){
window.clearInterval(timer);
$("popDiv").style.display = "none";
}
if(parseInt($("popDiv").style.height) >= 200){
window.clearInterval(timer);
}

}

var timer;
function runtimer(obj){
timer = window.setInterval(function(){pop(obj)},10);
}
window.onload = function(){
runtimer(2);
}
</script>
</head>
<body>
<div style="position:absolute;right:0;bottom:0;height:0px;width:200px;border:1px solid red;" id="popDiv">
<a href="javascript:runtimer(-2);void(0)">×</a>
</div>
</body>
</html> 如果看不明白请准问

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网