当前位置: 首页 > 图文教程 > 网络编程 > ASP > 如何固定表格的标题行和标题列

ASP
连接数据库查询手册
ASP.net组件编程中的两种事件编写方法
简单快捷实现ASP在线发邮件
ASP能读写注册表
用ASP实现在线压缩与解压缩
Asp编写不再让人讨厌的自动弹出窗口
使用组件封装ASP的数据库操作
删除Access数词库中的空记录
制做行背景颜色交替变换的表格
将数据库中的信息存储至XML文件中
如何用foreach遍历页面上所有的TextBox
asp.net如何生成图片验证码(简单)
WEB表格导出为EXCEL文档的方法
ASP上两个防止SQL注入式攻击Function
xmlHTTP技术资料
提高ASP.NET性能的方法
DataGrid 分页问题
如何固定表格的标题行和标题列
在B/S系统中引入定时器的功能
关于用ASP.Net识别远程主机服务器种类

ASP 中的 如何固定表格的标题行和标题列


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 17 ::
收藏到网摘: n/a

网上有许关于固定表格的标题行的文章,但是既要固定标题行又要固定标题列的却几乎没有。现我写下如下代码以供大家参考:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<script>
function syncscroll(obj)
{
 y.innerHTML = obj.scrollTop;
 x.innerHTML = obj.scrollLeft;
 scroll1.children[0].style.position = "relative";
 scroll2.children[0].style.position = "relative";
 scroll1.children[0].style.left = "-"+obj.scrollLeft;
 scroll2.children[0].style.top =  "-"+obj.scrollTop;
 
}
</script>
<body>
<table border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>
  <!--*****************************************************左上-BEGIN*****************************************************-->

  <table width="240" height="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#666666">
   <colgroup>
   <col width="80" >
   <col width="80" >
   <col width="80" >
   </colgroup>
    <tr bgcolor="#FFFFFF">
   <td height="20">&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
    </tr>
  </table>

  <!--*****************************************************左上-END*****************************************************-->
 </td>
    <td>
 <div id='scroll1' style="width:450;overflow:hidden ">
  <!--*****************************************************右上-BEGIN*****************************************************-->

  <table style="width:900 " height="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#666666">
   <colgroup>
   <col width="150" >
   <col width="150" >
   <col width="150" >
   <col width="150" >
   <col width="150" >
   </colgroup>
    <tr bgcolor="#FFFFFF">
   <td>&nbsp;</td>
   <td height="20">&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
    </tr>
  </table>

  <!--*****************************************************右上-END*****************************************************-->
 </div>
 </td>
  </tr>
  <tr>
    <td align="left" valign="top">
 <div id='scroll2' style="height:150;overflow-y:hidden;overflow-x:scroll">
  <!--*****************************************************左下-BEGIN*****************************************************-->

  <table width="240" height="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#666666">
   <colgroup>
   <col width="80" >
   <col width="80" >
   <col width="80" >
   </colgroup>

    <tr bgcolor="#FFFFFF">
   <td height="20">&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
    </tr>
    &