日期:2014-05-16  浏览次数:21013 次

ie6下不兼容,求高手看这句js如何改?
这代码在ie6下无效了。。请问如何弄才可以兼容?
就是下拉到一定距离,div会固定在浏览器顶部的。在ie6下失效。

<script type="text/javascript" src="jquery.min.js"></script>
<style>
.auto_fixed_top{width:300px;} 
.fixed_top{position:fixed;_position:absolute;top:0;z-index:900;}
</style>
内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>
内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>
<div class="auto_fixed_top">

浮动固定浮动固定浮动固定浮动固定浮动固定浮动固定浮动固定

</div>
内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>
内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>
内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>

内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>
内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>
内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>
内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>
内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>内容<br>



<script type="text/javascript" >
$(function(){
if ($('.auto_fixed_top').size() > 0){
  $(window).scroll(function(){
     var scrollTop = parseInt($(document).scrollTop());
     if (scrollTop > 165){
        $('.auto_fixed_top').addClass('fixed_top');
     }else{
        $('.auto_fixed_top').removeClass('fixed_top');
     }
  });
}  
}); 

</script>

------解决方案--------------------
这样
.auto_fixed_top{width:300px;} 
.fixed_top{position:fixed;top:0;z-index:900;}


* html,* html body{background-image:url(about:blank);background-attachment:fixed} 
*html   .fixed_top{!important;position:absolute;
left:expression(eval(document.documentElement.scrollLeft));top:expression(eval(document.documentElement.scrollTop));} 

<script type="text/javascript" >
$(function(){
if ($('.auto_fixed_top').size() > 0){
  $(window).scroll(function(){
     var scrollTop = parseInt($(document).scrollTop());
     if (scrollTop > 165){
        $('.auto_fixed_top').addClass('fixed_top');
     }else{
        $('.auto_fixed_top').removeClass('fixed_top');
     }