首页 热点资讯 义务教育 高等教育 出国留学 考研考公

javascript怎么触发滚动条事件

发布网友 发布时间:2022-04-23 04:23

我来回答

2个回答

热心网友 时间:2022-04-22 20:44

你是不是想固定表头啊
<style>
.DataGridFixedHeader
{
position: absolute;
overflow: hidden;
top: expression(document.getElementById('dv1').scrollTop-2);
left: 6px;
}
</style>
/////
//
////
<asp:GridView ID="gvPl" runat="server" CellPadding="4" ForeColor="#333333" GridLines="Horizontal"
AutoGenerateColumns="False" Width="1500px"
AllowSorting="True" OnRowCommand="gvPl_RowCommand" OnRowDataBound="gvPl_RowDataBound" OnSorting="gvPl_Sorting" >
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="Lavender" Font-Bold="False" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" Font-Names="宋体"
Font-Size="9pt" CssClass="DataGridFixedHeader" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField ShowHeader="False" Visible="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="false" CommandName="Ed"
ImageUrl="~/images/smalledit.gif" Text="修改" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False" Visible="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="false" CommandName="Dele"
Text="删除" OnClientClick="return confirm('您确认删除该记录吗?');"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="序号">
<ItemStyle HorizontalAlign="Center" Wrap="False" />
<HeaderStyle Wrap="False" />
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# ++iRowCount %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:BoundField HeaderText="项目包" DataField="SortName" SortExpression="SortName" >
<HeaderStyle Wrap="False" HorizontalAlign="Center" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="ItemCode" HeaderText="项目编号" SortExpression="ItemCode">
<ItemStyle Wrap="False" />
<HeaderStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField HeaderText="项目名称" DataField="ItemName" SortExpression="ItemName">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="ItemChkCode" HeaderText="项目批复文号" SortExpression="ItemChkCode">
<ItemStyle Wrap="False" />
<HeaderStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField HeaderText="资产属性" DataField="AssetPName" SortExpression="AssetPName">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="项目性质" DataField="BudgetPName" SortExpression="BudgetPName">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="建设单位" DataField="BuildName" SortExpression="BuildName">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField HeaderText="物资名称" DataField="MERCHNAME" SortExpression="MERCHNAME">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField HeaderText="型号规格" DataField="MODEL" SortExpression="MODEL">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField HeaderText="计量单位" DataField="MEASURENAME">
<HeaderStyle Wrap="False" />
<ItemStyle HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField HeaderText="数量" DataField="Num" DataFormatString="{0:N6}" HtmlEncode="False"
SortExpression="Num">
<HeaderStyle Wrap="False" />
<ItemStyle HorizontalAlign="Right" Wrap="False" />
</asp:BoundField>
<asp:BoundField HeaderText="单价" DataField="SinglePrice" DataFormatString="{0:N6}"
HtmlEncode="False" SortExpression="SinglePrice">
<HeaderStyle Wrap="False" />
<ItemStyle HorizontalAlign="Right" Wrap="False" />
</asp:BoundField>
<asp:BoundField HeaderText="金额" DataField="TotlePrice" DataFormatString="{0:N}"
HtmlEncode="False" SortExpression="TotlePrice">
<HeaderStyle Wrap="False" />
<ItemStyle HorizontalAlign="Right" Wrap="False" />
</asp:BoundField>
<asp:BoundField HeaderText="交货时间" DataField="PutinMaterialTime" DataFormatString="{0:yyyy-MM-dd}"
HtmlEncode="False" SortExpression="PutinMaterialTime">
<HeaderStyle Wrap="False" />
<ItemStyle HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="PutinMaterialDD" HeaderText="交货地点" SortExpression="PutinMaterialDD">
<ItemStyle HorizontalAlign="Left" Wrap="False" />
<HeaderStyle Wrap="False" />
</asp:BoundField>

<asp:BoundField DataField="TenderCompanyName" HeaderText="中标单位" SortExpression="TenderCompanyName">
<ItemStyle HorizontalAlign="Left" Wrap="False" />
<HeaderStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Remark" HeaderText="备注" >
<ItemStyle HorizontalAlign="Left" Wrap="False" />
<HeaderStyle Wrap="False" />
</asp:BoundField>
<asp:TemplateField ShowHeader="False" Visible="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Select"
Text="选择"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<asp:Table ID="Table1" runat="server" BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
Height="22px" Width="1500">
<asp:TableRow ID="TableRow1" runat="server">
<asp:TableCell ID="TableCell10" runat="server">序号</asp:TableCell>
<asp:TableCell ID="TableCell8" runat="server">项目包</asp:TableCell>
<asp:TableCell ID="TableCell1" runat="server">项目编号</asp:TableCell>
<asp:TableCell ID="TableCell2" runat="server">项目名称</asp:TableCell>
<asp:TableCell ID="TableCell3" runat="server">项目批复文号</asp:TableCell>
<asp:TableCell ID="TableCell4" runat="server">资产属性</asp:TableCell>
<asp:TableCell ID="TableCell9" runat="server">项目性质</asp:TableCell>
<asp:TableCell ID="TableCell11" runat="server">建设单位</asp:TableCell>
<asp:TableCell ID="TableCell26" runat="server">原合同号</asp:TableCell>
<asp:TableCell ID="TableCell19" runat="server">物资名称</asp:TableCell>
<asp:TableCell ID="TableCell20" runat="server">型号规格</asp:TableCell>
<asp:TableCell ID="TableCell6" runat="server">计量单位</asp:TableCell>
<asp:TableCell ID="TableCell7" runat="server">数量</asp:TableCell>
<asp:TableCell ID="TableCell12" runat="server">采购单价</asp:TableCell>
<asp:TableCell ID="TableCell13" runat="server">采购金额</asp:TableCell>
<asp:TableCell ID="TableCell16" runat="server">交货时间</asp:TableCell>
<asp:TableCell ID="TableCell22" runat="server">交货地点</asp:TableCell>
<asp:TableCell ID="TableCell17" runat="server">中标单位</asp:TableCell>
<asp:TableCell ID="TableCell25" runat="server">备注</asp:TableCell>
</asp:TableRow>
</asp:Table>
</EmptyDataTemplate>
<EmptyDataRowStyle CssClass="GvEmptyDataStyle" />
<EditRowStyle BackColor="#E2DED6" />
</asp:GridView>

热心网友 时间:2022-04-22 22:02

<script type="text/javascript">
window.onscroll=function(){
var oDiv=document.getElementById("div1");
oDiv.style.top=document.documentElement.scrollTop;

}
</script>
代码里面的onscroll事件就是当拖动滚动条时触发

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com