实现的 目的是判断下拉的时候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>
<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>
解决方案 »
- 加载多个action
- iframe页面上的按钮重定向当前子页面的问题
- 子窗口刷新父窗口问题
- Javascript描点问题
- 请问这段代码是什么意思?.add
- 晕了... Array.prototype.obj 的 obj.subobj 继承问题
- ~~~~~~~~~~~~~~~~动态添加thead问题,马上给分!~~~~~~~~~~~~~~~~~~~
- 怎样用Javascript检测用户关闭窗口事件?急
- emu(ston)哥!您随便打几个字,我给您分!(别怪我给得少,因为我很菜,分不多)
- 本人想学JAVA,但不知用什么开发工具好呀?
- nodejs和普通的js是不是不能混在一起写?
- 如何提交验证成功后才改更按钮的值呢。
if(headerWrap.top="0"){//这里你确定是赋值=,而不是比较运算符===??这里永远为真。
headerWrap.className='fixed';
}else{
headerWrap.className='header-wrap';
}
我 这个是判断headerWrap是否达到最顶端,用比较运算符headerWrap.top==0没有一点反应