一个右下角浮动窗口的有关问题
一个右下角浮动窗口的问题
以下代码已经实现右下角浮动窗口,但是现在要实现窗口距离底部50px的距离,就不会搞了,请大神帮帮忙
------解决方案--------------------
以下代码已经实现右下角浮动窗口,但是现在要实现窗口距离底部50px的距离,就不会搞了,请大神帮帮忙
<script type="text/javascript" src="jquery.js"></script>
<script language="javascript">
function ShowMessage(widht,height) {
var TopY=0;//初始化元素距父元素的距离
$("#mymessage").css("width",widht+"px").css("height",height+"px");//设置消息框的大小
$("#mymessage").slideDown(1000);//弹出
$("#message_close").click(function() {//当点击关闭按钮的时候
if(TopY==0){
$("#mymessage").slideUp(1000);//这里之所以用slideUp是为了兼用Firefox浏览器
}
else
{
$("#mymessage").animate({top: TopY+height}, "slow", function() { $("#mymessage").hide(); });//当TopY不等于0时 ie下和Firefox效果一样
}
});
$(window).scroll(function() {
$("#mymessage").css("top", $(window).scrollTop() + $(window).height() - $("#mymessage").height());//当滚动条滚动的时候始终在屏幕的右下角
TopY=$("#mymessage").offset().top;//当滚动条滚动的时候随时设置元素距父原素距离
});
}
$(function(){
ShowMessage(252,166);
})
</script>
<style type="text/css">
#mymessage{
right: 0px;
margin-bottom:0px;
bottom: 0px;
position: absolute;
z-index: 999;
display:none;
}
</style>
<div id="mymessage">
<a id="message_close" title="点击关闭" href="javascript:void(0);"><div id="mes_close" style="background-image:url(tpl/window/top.jpg); width:252px; height:22px; background-repeat:no-repeat;"></div></a>
<a href="index.php?c=pro&a=show&id=<?=$rs[links]?>" target="_blank" style="text-decoration: none;">
<table width="250" height="144" border="0" cellpadding="0" cellspacing="0" style="background-image:url(tpl/window/moban.jpg); background-repeat:no-repeat;">
<tr>
<td height="30" align="center" style="color:#304759; font-size:14px; font-weight:bold"><?=$rs[title]?></td>
</tr>
<tr>
<td align="left" valign="top"><table width="252" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="98" align="center" style="text-align:center; padding-left:5px"><img src="<?=$rs[picurl]?>" width="80" height="80" border="0" /></td>
<td width="152" align="left" valign="top" style="color:#304759; font-size:12px;"> <?=$rs[content]?></td>
</tr>
</table></td>
</tr>
</table>
</a>
</div>
------解决方案--------------------
<script type="text/javascript" src="/js/jquery-1.2.6.min.js"></script>
<script language="javascript">
function ShowMessage(width,height,bottom) {
typeof bottom=='undefined'?bottom=50:0;
var TopY=0;//初始化元素距父元素的距离
$("#mymessage").css("width",width+"px").css("height",height+"px");//设置消息框的大小
$("#mymessage").slideDown(1000);//弹出
$("#message_close").click(function() {//当点击关闭按钮的时候
if(TopY==0){
$("#mymessage").slideUp(1000);//这里之所以用slideUp是为了兼用Firefox浏览器
}
else
{
$("#mymessage").animate({top: TopY+height}, "slow", function() { $("#mymessage").hide(); });//当TopY不等于0时 ie下和Firefox效果一样
}
});
$(window).scroll(function() {
$("#mymessage").css("top", $(window).scrollTop() + $(window).height() - $("#mymessage").height()-bottom);//当滚动条滚动的时候始终在屏幕的右下角
TopY=$("#mymessage").offset().top;//当滚动条滚动的时候随时设置元素距父原素距离
});
}
$(function(){
ShowMessage(252,166);
})
</script>
<style type="text/css">
#mymessage{
right: 0px;
margin-bottom:0px;
bottom: 50px;