当前位置:首页 > 开发教程 > Web前端 >

jquery实现滚动到导航后悬浮停止页面顶部 兼容ie6

时间:2014-12-30 11:51 来源:互联网 作者:源码搜藏 收藏

script type=text/javascript$(function(){if ($.browser.msie ($.browser.version == 6.0) !$.support.style) {var handler,sTop,dTop;dTop = $(#fixedNav).offset().top $(window).bind(scroll,function(){ window.clearTimeout(handler); handler = windo
<script type="text/javascript">
$(function(){

if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
var handler,sTop,dTop;
				dTop = $("#fixedNav").offset().top
    $(window).bind('scroll',function(){
        window.clearTimeout(handler);
        handler = window.setTimeout(function(){
            sTop = $(document).scrollTop();
            sTop > dTop  $("#fixedNav").css("top",sTop - dTop) : $("#fixedNav").css("top",0);
	    $("#fixedNav").css({"position":"relative","z-index":"1200"});
        },60);
    });
}else{

	var topMain= $("#fixedNav").offset().top
 $(window).scroll(function(){
  if ($(window).scrollTop()>topMain){
   $("#fixedNav").addClass("nav_scroll");
  }else{
   $("#fixedNav").removeClass("nav_scroll");
  }
 });

	}
});
</script>
.nav_scroll{ position:fixed;top:0;left:0;z-index:1200; width:100%;}

Web前端阅读排行

最新文章