返回顶部,侧栏广告 跟随浏览器移动
一个简单的小功能
<!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>
<style type="text/css">
html,body
{
width:100%;
height:100%;
margin:0px;
padding:0px;
}
</style>
<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$(function(){
var gotop_pv=$.browser.msie&&$.browser.version <7?"absolute":"fixed";
var gotop_top=$(window).height()-100;
var gotop_right=10;
$("body").append("<a id='gotop' style='position:"+gotop_pv+";top:"+gotop_top+"px;right:"+gotop_right+"px;'>返回顶部</a>");
$("#gotop").click(function(){
$(window).scrollTop(0);
})
if($.browser.msie&&$.browser.version <7)
{
$(window).scroll(function () {
$("#gotop").css("top",$(window).scrollTop()+gotop_top+"px");
})
.resize(function(){
$("#gotop").css("top",$(window).scrollTop()+gotop_top+"px");
})
}
})
</script>
</head>
<body>
a<br>a<br>a<br>acc<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>agbb<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>
a<br>a<br>a<br>a<br>a111<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>
a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>1xxx11a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>
a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
html,body
{
width:100%;
height:100%;
margin:0px;
padding:0px;
}
</style>
<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$(function(){
var gotop_pv=$.browser.msie&&$.browser.version <7?"absolute":"fixed";
var gotop_top=$(window).height()-100;
var gotop_right=10;
$("body").append("<a id='gotop' style='position:"+gotop_pv+";top:"+gotop_top+"px;right:"+gotop_right+"px;'>返回顶部</a>");
$("#gotop").click(function(){
$(window).scrollTop(0);
})
if($.browser.msie&&$.browser.version <7)
{
$(window).scroll(function () {
$("#gotop").css("top",$(window).scrollTop()+gotop_top+"px");
})
.resize(function(){
$("#gotop").css("top",$(window).scrollTop()+gotop_top+"px");
})
}
})
</script>
</head>
<body>
a<br>a<br>a<br>acc<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>agbb<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>
a<br>a<br>a<br>a<br>a111<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>
a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>1xxx11a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>
a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>
</body>
</html>