想实现可关闭的网页底部图片广告 http://www.lanrentuku.com/lanren/jscode/js-0002/http://www.lanrentuku.com/lanren/jscode/js-0002.rar 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!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:0; bottom:0; 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; font-size:12px; color:#FF0000; text-decoration:underline; text-align:center}#silu { font-size:13px; color:#999999; position:absolute; right:0;bottom:0px; text-align:right; text-decoration:underline; line-height:22px;}.close { position:absolute; right:4px; top:-1px; color:#FFFFFF; cursor:pointer}</style><script type="text/javascript">function show_pop(){//显示窗口 document.getElementById("winpop").style.display="block"; timer=setInterval("changeH(4)",2);//调用changeH(4),每0.002秒向上移动一次}function hid_pop(){//隐藏窗口 timer=setInterval("changeH(-4)",2);//调用changeH(-4),每0.002秒向下移动一次}function changeH(addH) { var MsgPop=document.getElementById("winpop"); var popH=parseInt(MsgPop.style.height||MsgPop.currentStyle.height);//用parseInt将对象的高度转化为数字,以方便下面比较(JS读<style>中的height要用"currentStyle.height") if (popH<=100&&addH>0||popH>=4&&addH<0){//如果高度小于等于100(str>0)或高度大于等于4(str<0) MsgPop.style.height=(popH+addH).toString()+"px";//高度增加或减少4个象素 } else{//否则 clearInterval(timer);//取消调用,意思就是如果高度超过100象素了,就不再增长了,或高度等于0象素了,就不再减少了 MsgPop.style.display=addH>0?"block":"none"//向上移动时窗口显示,向下移动时窗口隐藏(因为窗口有边框,所以还是可以看见1~2象素没缩进去,这时候就把DIV隐藏掉) }}window.onload=function(){//加载setTimeout("show_pop()",800);//0.8秒后调用show_pop()}</script><body><div id="silu"><br /><button onclick="show_pop()">测试按钮</button></div><div id="winpop"> <div class="title">您有新的消息<span class="close" onclick="hid_pop()">X</span></div> <div class="con">未读信息(1)</div></div></body></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; left:1px; bottom:0; 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; font-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 show_pop(){//显示窗口 $("winpop").style.display="block"; timer=setInterval("changeH(4)",2);}function hid_pop(){//隐藏窗口 timer=setInterval("changeH(-4)",2);}function changeH(addH) {//窗口展缩 var MsgPop=$("winpop"); var popH=parseInt(MsgPop.style.height||MsgPop.currentStyle.height); var popT=parseInt(MsgPop.offsetTop); if (popH<=100&&addH>0||popH>=4&&addH<0){ MsgPop.style.height=(popH+addH)+"px"; MsgPop.style.top=popT-addH+"px"; } else{ clearInterval(timer); MsgPop.style.display=addH>0?"block":"none" if (addH>0)timer=setInterval(Float,1);//设置浮动 else {clearInterval(timer);} }}window.onload=function(){setTimeout("show_pop()",500);}</script><script language="JavaScript" type="text/javascript">/*--窗口浮动--*/function $(id){return document.getElementById(id)}function get_diffY(){//获取滚动条位置(顶高)值 var diffY if (document.documentElement && document.documentElement.scrollTop) diffY = document.documentElement.scrollTop; else if (document.body) diffY = document.body.scrollTop else diffY=0 return diffY}function get_diffH(){//获取窗口高 var diffH if (document.documentElement && document.documentElement.offsetHeight) diffH = document.documentElement.offsetHeight; else if (document.body) diffH = document.body.offsetHeight; else diffH=0 return diffH}var lastScrollY=0;function get_percent(){//获取浮动移动步幅 var percent=.1*(get_diffY()-lastScrollY); if(percent>0)percent=Math.ceil(percent); else percent=Math.floor(percent); return percent}function Float(){//窗口浮动 var percent=get_percent(); var obj=$("winpop"); obj.style.top=parseInt(obj.offsetTop)+percent+"px"; lastScrollY=lastScrollY+percent; }window.onresize=function(){ var obj=$("winpop"); obj.style.top=get_diffH()+"px"; lastScrollY=obj.offsetHeight+5; }</script><body><div id="winpop"> <div class="title">您有新的消息<span class="close" onclick="hid_pop()">X</span></div> <div class="con">未读信息(1)</div></div><div style="height:1000px"></div></body></html> 昨天前端面试经历 根据内容自动调整弹出窗口大小的JS解决方案 但只适合于FF 关于js的语句执行顺序 一个简单的字符替换问题 js弹出框,提交信息 如何使用javascript实现程序的pagecontrol功能 简单问题,在线等。 如何实现当鼠标在文本框上方时文本框中的内容选定,当鼠标不再文本框上方时文本框中的内容从选中状态变为不选中的状态!!!! 读xml的问题。 如何判断浏览器是否有缓存 多个文本框运算 请问这里的/怎么理解
<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:0; bottom:0; 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; font-size:12px; color:#FF0000; text-decoration:underline; text-align:center}
#silu { font-size:13px; color:#999999; position:absolute; right:0;bottom:0px; text-align:right; text-decoration:underline; line-height:22px;}
.close { position:absolute; right:4px; top:-1px; color:#FFFFFF; cursor:pointer}
</style>
<script type="text/javascript">
function show_pop(){//显示窗口
document.getElementById("winpop").style.display="block";
timer=setInterval("changeH(4)",2);//调用changeH(4),每0.002秒向上移动一次
}
function hid_pop(){//隐藏窗口
timer=setInterval("changeH(-4)",2);//调用changeH(-4),每0.002秒向下移动一次
}
function changeH(addH) {
var MsgPop=document.getElementById("winpop");
var popH=parseInt(MsgPop.style.height||MsgPop.currentStyle.height);//用parseInt将对象的高度转化为数字,以方便下面比较(JS读<style>中的height要用"currentStyle.height")
if (popH<=100&&addH>0||popH>=4&&addH<0){//如果高度小于等于100(str>0)或高度大于等于4(str<0)
MsgPop.style.height=(popH+addH).toString()+"px";//高度增加或减少4个象素
}
else{//否则
clearInterval(timer);//取消调用,意思就是如果高度超过100象素了,就不再增长了,或高度等于0象素了,就不再减少了
MsgPop.style.display=addH>0?"block":"none"//向上移动时窗口显示,向下移动时窗口隐藏(因为窗口有边框,所以还是可以看见1~2象素没缩进去,这时候就把DIV隐藏掉)
}
}
window.onload=function(){//加载
setTimeout("show_pop()",800);//0.8秒后调用show_pop()
}
</script>
<body>
<div id="silu">
<br />
<button onclick="show_pop()">测试按钮</button>
</div>
<div id="winpop">
<div class="title">您有新的消息<span class="close" onclick="hid_pop()">X</span></div>
<div class="con">未读信息(1)</div>
</div>
</body>
</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; left:1px; bottom:0; 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; font-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 show_pop(){//显示窗口
$("winpop").style.display="block";
timer=setInterval("changeH(4)",2);
}
function hid_pop(){//隐藏窗口
timer=setInterval("changeH(-4)",2);
}
function changeH(addH) {//窗口展缩
var MsgPop=$("winpop");
var popH=parseInt(MsgPop.style.height||MsgPop.currentStyle.height);
var popT=parseInt(MsgPop.offsetTop);
if (popH<=100&&addH>0||popH>=4&&addH<0){
MsgPop.style.height=(popH+addH)+"px";
MsgPop.style.top=popT-addH+"px";
}
else{
clearInterval(timer);
MsgPop.style.display=addH>0?"block":"none"
if (addH>0)timer=setInterval(Float,1);//设置浮动
else {clearInterval(timer);}
}
}
window.onload=function(){
setTimeout("show_pop()",500);
}
</script>
<script language="JavaScript" type="text/javascript">
/*--窗口浮动--*/function $(id){return document.getElementById(id)}
function get_diffY(){//获取滚动条位置(顶高)值
var diffY
if (document.documentElement && document.documentElement.scrollTop)
diffY = document.documentElement.scrollTop;
else if (document.body)
diffY = document.body.scrollTop
else
diffY=0
return diffY
}
function get_diffH(){//获取窗口高
var diffH
if (document.documentElement && document.documentElement.offsetHeight)
diffH = document.documentElement.offsetHeight;
else if (document.body)
diffH = document.body.offsetHeight;
else
diffH=0
return diffH
}var lastScrollY=0;
function get_percent(){//获取浮动移动步幅
var percent=.1*(get_diffY()-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
return percent
}function Float(){//窗口浮动
var percent=get_percent();
var obj=$("winpop");
obj.style.top=parseInt(obj.offsetTop)+percent+"px";
lastScrollY=lastScrollY+percent;
}window.onresize=function(){
var obj=$("winpop");
obj.style.top=get_diffH()+"px";
lastScrollY=obj.offsetHeight+5;
}</script><body>
<div id="winpop">
<div class="title">您有新的消息<span class="close" onclick="hid_pop()">X</span></div>
<div class="con">未读信息(1)</div>
</div>
<div style="height:1000px"></div>
</body>
</html>