欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于jquery的返回頂部效果(兼容IE6)

 更新時間:2011年01月17日 17:22:16   作者:  
最近在寫一個首頁返回頂部的效果,因為IE6不兼容position:fixed的原因,一直找不到好的解決辦法。在Google了一下,有了點眉目,加上一點自己的開發(fā),總算誤打誤撞的把問題解決了。
最近也在學jquery,就順便記錄一下了。

HTML
復制代碼 代碼如下:

<div class="scroll"></div>
<script type="text/javascript" src="../skins/css/jQuery.js" charset="UTF-8"></script>
<script type="text/javascript" src="../skins/css/top.js" charset="UTF-8"></script>

CSS
復制代碼 代碼如下:

.scroll{
background:url(../image/scroll.gif) no-repeat center top transparent;
bottom:100px;
cursor:pointer;
height:67px;
width:18px;
position:fixed;
_position:absolute; /*兼容IE6*/
_top: expression(eval(document.documentElement.scrollTop)+700); /*700為圖片距離頂部的設(shè)定距離,可以修改。不加700則圖片緊貼在頂部滾動*/
}
html{_text-overflow:ellipsis;} /*解決IE6下圖片抖動*/

top.js
復制代碼 代碼如下:

$(document).ready(function(){
var show_delay;
var scroll_left=parseInt((document.body.offsetWidth-960)/2)+961; //960為頁面寬度
$(".scroll").click(function (){
document.documentElement.scrollTop=0;
document.body.scrollTop=0;
});
$(window).resize(function (){
scroll_left=parseInt((document.body.offsetWidth-960)/2)+961;
$(".scroll").css("left",scroll_left);
});
reshow(scroll_left,show_delay);
});
function reshow(marign_l,show_d) {
$(".scroll").css("left",marign_l);
if((document.documentElement.scrollTop+document.body.scrollTop)!=0)
{
$(".scroll").css("display","block");
}
else
{
$(".scroll").css("display","none");}
if(show_d) window.clearTimeout(show_d);
show_d=setTimeout("reshow()",500);
}

最后不要忘記了jQuery.js文件哦!

相關(guān)文章

最新評論