实现的 目的是判断下拉的时候headerWrap是否 在最顶端,如果在最顶断就一直显示在上面 。下拉过程中 位置一直不变,虽然位置 不变了 ,但是样式发生了改变  ,麻烦大家 看下啥问题   谢谢<!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 runat="server">
    <title>客户查找</title>
    <style type="text/css">
        body
        {
            font-family: 微软雅黑;
            font-size: 11px;
               
        
        }
           
    td
    {
     text-align:left;
    }
   
 *{ margin: 0; padding: 0; }
  .header-wrap{ width: 100%; }  .fixed{ position: fixed;width:100%;_top:expression(eval(document.documentElement.scrollTop));} 
 
 *html{
    background-image:url(about:blank);
    background-attachment:fixed;
}
   
  
    </style>
</head>
 
 <script type="text/javascript">
  window.onload=function(){
   function adsorption(){
    var headerWrap=document.getElementById('header-wrap');
    var scrollTop=0;
    window.onscroll=function(){
     
   //判断下拉的时候是否在最顶端    
    if(headerWrap.top="0"){
      headerWrap.className='fixed';
     }else{
      headerWrap.className='header-wrap';
     }
    }
   }
   adsorption();
  }
 </script>
<body style="height:5000px;">
<div style="height:80px"></div>
<table border="1px" cellpadding="0" cellspacing="0" width="100%">    
<tr  id="header-wrap" class="header-wrap"> 
<th>展会接待</th>
<th>分配跟进</th>
<th>报价</th>
<th>公司名称</th>
<th>国家代码</th>
</tr>
</table>

解决方案 »

  1.   

    [code=delphi]
      if(headerWrap.top="0"){//这里你确定是赋值=,而不是比较运算符===??这里永远为真。
          headerWrap.className='fixed';
         }else{
          headerWrap.className='header-wrap';
         }
      

  2.   

    而且你这个需求使用Css样式的position:fixed就可以了。
      

  3.   


    我 这个是判断headerWrap是否达到最顶端,用比较运算符headerWrap.top==0没有一点反应
      

  4.   

    window.onscroll 的时候 headerWrap.top会变化吗