Question

Table headers always visible

Asked by: eirikur

Hello,

I've got a nice table with ten columns and x rows (dynamically generated) and I want to make the table headers always visible, even if I'm scrolling down the page, but WITHOUT frames please !
The solution must be working on at least IE 5.

Thank you,

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-03-02 at 08:39:42ID20904188
Tags

table

,

scroll

Topic

Hypertext Markup Language (HTML)

Participating Experts
7
Points
125
Comments
17

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. JTable - header not visible
    Hello, I've subclassed the JTable and AbstractTableModel classes in order to create a table with a specific look that would be easy to instantiate. Anyhow, I can't seem to get the table header to show up and I'm just wondering what I have to do to make it visible... If you...
  2. List index visible in scrollpane
    Hi I have a simple JList put into a scrollpane so that only a few rows are viisble at a time. I want to ensure that if any row in the List box is selected, it should be visible. The method ensureIndexIsVisible of JList doesnt seems to work when the JList is in a scrollpane...
  3. MSFlexGrid Row Visibility
    Does anyone know how to determine if a given row of an MSFlexGrid is currently displayed (in the visible region of the screen), i.e., it has not been scrolled outside of the visible area of the grid? Failing that, does anyone know how to determine if the vertical scrollbar i...
  4. Ensure table row is visible
    I have a JTable embedded into a JScrollPane. I set the selected row in the table, using setRowSelectionInterval. But I also want to ensure that the selected row gets visible on the scrolling viewport. I guess I have to calculate the scrolling index from the table row to set...
  5. Frames that scroll into view
    I would like to know if its possible to have 2 frames frame 1 will be the maximum height of the window & frame2 will be not be visible ei: height = 0 is there way to make frame 2 scroll up into view with its contents & then make is scroll down again...kinda like a ...
  6. scrolling in frames?
    I have a site built with a frameset. It looks like this: <frameset rows="102,*" frameSpacing="0" frameBorder="0"> <frame name="header" src="header.aspx" scrolling="no" noresize> <frameset cols=&qu...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: dgelinasPosted on 2004-03-02 at 09:10:10ID: 10496804

You can make a table for the header consisiting of one row and a table for the body.  

 

by: seanpowellPosted on 2004-03-02 at 09:55:24ID: 10497239

Here's a static example. Basically you're just creating a scrollable div around the table rows...

<html>
<head>
<style type="text/css">
#header { background-color:#ccc; }
#scroll { overflow: auto; width: 480px; height:70px; padding:0px; margin: 0px }
</style>
</head>
<body>

<table cellspacing="0" cellpadding="2" id="header">
  <col width="100">
  <col width="150">
  <col width="218">
  <tr>
    <td>Category</td>
    <td>Name</td>
    <td>Description</td>
  </tr>
</table>

<div id="scroll">
<table cellspacing="0" cellpadding="2">
  <col width="100">
  <col width="150">
  <col width="200">
  <tr>
    <td>Category 1</td>
    <td>Name 1</td>
    <td>Description 1</td>
  </tr>
  <tr>
    <td>Category 2</td>
    <td>Name 2</td>
    <td>Description 2</td>
  </tr>
  <tr>
    <td>Category 3</td>
    <td>Name 3</td>
    <td>Description 3</td>
  </tr>
  <tr>
    <td>Category 4</td>
    <td>Name 4</td>
    <td>Description 4</td>
  </tr>
  <tr>
    <td>Category 5</td>
    <td>Name 5</td>
    <td>Description 5</td>
  </tr>
</table>
</div>

</body>
</html>

 

by: tim_csPosted on 2004-03-02 at 11:34:50ID: 10498221

<SCRIPT language="JavaScript">
<!--

// creates functions to have table header
// scroll with the page.
   var scrollbase=0;
   var ELpntr=false;
   var resetval=0;
   var NS=(document.layers) ? true : false;
   var IE=(document.all) ? true : false;

   function DetectB()
   {
// most of the cross-browser stuff get taken care of here
      if (NS)
      {
         ELpntr=document.HeadTable;
      }
      else
      {
         ELpntr=document.all.HeadTable.style;
         ELpntr.ypos=parseInt(ELpntr.top);
         resetval=scrollbase;
      }
      resetROW();
   }

   function resetROW()
   {
      if(IE)
      {
         resetval = document.body.scrollTop;
         ELpntr.ypos = resetval;
         if(ELpntr.ypos >= 15)  // Change this 15
               {
                     ELpntr.top = (ELpntr.ypos - 15); // replace this 15 with the same number.
               }
         else
               {
                     ELpntr.top = scrollbase;
               }
         resetval = scrollbase;
      }
      else
      {
         eval(ELpntr.top)=eval(window.pageYOffset);
      }
      setTimeout('resetROW()',100);
   }
//-->
</SCRIPT>

<BODY onLoad="DetectB()">

<div ID="HeadTable" style=" position: relative;top: 0;left: 0;">


<table style="padding-left: 8px; border: 1px solid black;" border='0' cellspacing="0" cellpadding="0" valign="top" bgcolor="papayawhip">




      <tr bgcolor="##FE9900" style="color: white;" valign="bottom">
            <td>test</td>
            <td>test</td>
            <td>test</td>
            <td>test</td>
            <td>test</td>
            <td>test</td>
            <td>test</td>
            <td>test</td>
            <td>test</td>
            <td>test</td>
            <td>test</td>
            <td>test</td>
      </tr>


</table>
</div>



<table style="padding-left: 8px; border: 1px solid black;" border='0' cellspacing="0" cellpadding="0" valign="top" bgcolor="papayawhip">


<tr>
                  <td>test</td>
                  <td>test</td>
                  <td>test</td>
                  <td>test</td>
                  <td>test</td>
                  <td>test</td>
                  <td>test</td>
                  <td>test</td>
                  <td>test</td>
                  <td>test</td>
                  <td>test</td>
                  <td>test</td>
            </tr>

                        <tr>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
            </tr>

                        <tr>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
                              <td>test</td>
            </tr>

</table>

On the Javascript part you need to replace the "15" with the number of pixels down the header table is and also replace the "15" right below it with the same number. You can just randomly put numbers into it till you get it to the right number of pixels. After that the header will stay in place until the top of the screen hits it then it will move down with the screen.

 

by: COBOLdinosaurPosted on 2004-03-02 at 12:20:41ID: 10498684

Tim, I hope you realize that when I wrote that very old method, that it was only designed to support IE and Netscrap 4. It will not work for Mozilla or any orther modern browser except IE.

I don't know which thread you cut it from but I do appreciate aknowledgement.

Now for this to work with variable width heading there are a couple of approaches. The first is IE only and is IMHO really defective.  It can be made cross browser but by getting rid of the set expression and setting the with through the dom, but that is even more backward than the IE specific method. The second approach does not work for IE because they talk a good game on open standards, but have failed to support them every chance they get.  The second approach is elegant and clean, and looks gourgeious in Mozilla, and it is one of the reason we are moving our client off of IE to standardization on Mozilla 1.6.

The defective IE approach:

<html>
<head>
<script language="javascript">
window.onload = init;
function init() {
var eTable = document.getElementById("headers");
eTable.style.setExpression("width","document.getElementById('data').offsetWidth");
document.getElementById('th1').style.setExpression("width","document.getElementById('td1').offsetWidth");
document.getElementById('th2').style.setExpression("width","document.getElementById('td2').offsetWidth");
document.getElementById('th3').style.setExpression("width","document.getElementById('td3').offsetWidth");
document.getElementById('th4').style.setExpression("width","document.getElementById('td4').offsetWidth");
}
</script>
<style>
table#headers, table#data {table-layout:fixed;background:#dda0dd;}
td, th {vertical-align:top;background:#ffffff;}
</style>
</head>
<body>
<table cellpadding="4" cellspacing="1" id="headers">
<tr>
<th id="th1">Test</th>
<th id="th2">Hello</th>
<th id="th3">Yoohoo</th>
<th id="th4">Hmm</th>
</tr>
</table>
<div style="width:100%;height:300px;overflow:auto;">
<table cellpadding="4" cellspacing="1" width="100%" id="data">
<tr>
<td id="td1">Data</td>
<td id="td2">Hello</td>
<td id="td3">I am here and so are you</td>
<td id="td4">Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I...........................................xxxxxxxxxxxxxxxxxxxxxx</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
</table>
</div>
</body>
</html>



The better way:

<html>
<head>
<style>
td {padding:5px; }
</style>
</head>
<body>
<table style="width:600px" border="1" id="header">
<thead>
<tr>
<th>Test</th>
<th>Hello</th>
<th>Yoohoo</th>
<th>Hmm</th>
<th style="width:15px">&nbsp;</th>
</tr>
</thead>
<tbody style="width:600px;height:300px;overflow:auto;">
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are youuuuuuuuuuuuuuuuuuuuu</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Dataaaaaaaa</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are youuuuuuuuuuuuuuuuuuuuuuu</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
<tr>
<td>Data</td>
<td>Hello</td>
<td>I am here and so are you</td>
<td>Yoohoo</td>
</tr>
</tbody>
</table>
</body>
</html>

Cd&

 

by: tim_csPosted on 2004-03-02 at 12:46:29ID: 10498978

First. Someone pointed me to that code a while back when I had a problem. I modified it some to meet my own needs. Had I known who I got it from and that they would be so angry about me helping out another person with it then I would have given you credit. As far as your solutions. The first one is great if he wants his data inside of a scrolling box. The second one as you stated doesn't work in IE with if you read his post he says "The solution must be working on at least IE 5." so that does him a lot of good.

 

by: COBOLdinosaurPosted on 2004-03-02 at 13:27:04ID: 10499413

That old approach is not very useful unless the only thing on the page is the table and that the desired position is the top of the page.  Try integrating it into another page or position it half way down the page.

It became obsolete as soon as the support for teh overflow property stablized.  The heading do not stay fixed.  They jump around because there is a latency between iterations of the positioning function.  It was alright in its day but so was was the 80286 processor.

What Sean posted, and what I posted support current standards.  Sean's is cross-browser. The first of mine can be made cross-browser.  I also address the problem of variable width data, and Sean's can be adapted to do to that.

BTW. for IE6 it might or might not work, depending on the doctype.  With a strict doctype, document.body.scrollTop no longer exists.  It must be referenced as document.documentElement.scrollTop

Cd&

 

by: brunobearPosted on 2004-03-02 at 13:58:51ID: 10499687

what about this one Cd&?  THis one was yours...


<html>
<head>
  <title> scrollable table</title>
<style>
  body {background-color:moccasin}
  th {color:snow;background-color:darkkhaki}
  td {color:navajowhite;background-color:navy}
  .maindiv {background-color:tan}
</style>
<body>
  <div style="position:absolute;left:100;top:10">
     <table frame="border" width = 480>
        <col width=80>
        <col width=80>
        <col width=80>
        <col width=80>
        <col width=80>
        <col width=80>
        <tr>
           <th>first</th>
           <th>second</th>
           <th>third</th>
           <th>fourth</th>
           <th>fifth</th>
           <th>sixth</th>
        </tr>    
     </table>
     <div class="maindiv" STYLE="overflow-X:hidden;overflow-y:scroll;width:496;height:300;">
        <table frame="border" width=480 height=1200 >
        <col width=80>
        <col width=80>
        <col width=80>
        <col width=80>
        <col width=80>
        <col width=80>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
        <tr>
           <td height=60>Cd&</td>
           <td height=60>:^)</td>
           <td height=60>colC</td>
           <td height=60>xxxx</td>
           <td height=60>:^)</td>
           <td height=60>Cd&</td>
        </tr>
     </table>
  </div>    
  <table border=1 width=480 bgcolor="silver">
     <col width = 80>
     <col width = 80>
     <col width = 80>
     <col width = 80>
     <col width = 80>
     <col width = 80>
     <tr>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
     </tr>    
  </table>
</div>
</body>
</html>

 

by: brunobearPosted on 2004-03-02 at 13:59:21ID: 10499690

which was the one i posted, btw, when tim_cs asked HIS question on how to do this...


http://www.experts-exchange.com/Web/Q_20844907.html

 

by: seanpowellPosted on 2004-03-02 at 14:03:29ID: 10499723

That will also work - it does use overflow-x and y though, which are MS only additions. There's probably countless variations on the theme.

1. A static and inflexible one that I posted above.
2. A more robust dynamic version using scripting that Cd& posted.

All depends on one's needs. Let's wait until we get a better idea of what the asker is looking for before we go any further :-)

Thanks,
Sean

 

by: COBOLdinosaurPosted on 2004-03-02 at 14:28:02ID: 10499913

The  overflow-x:hidden;overflow-y:scroll  came from IE4 support befroe non-IE browsers knew what it was.  Later got modified to overflow:auto;overflow-x:hidden when Netscrap/mozilla added support, but IE often insisted on putting in a horizontal scroll when it was not needed.  With modern browsers overflow:auto gets pretty consistent rendering.

Cd&

 

by: COBOLdinosaurPosted on 2004-03-02 at 14:29:49ID: 10499922

I still like the standards compliant tbody method and maybe by IE 9.4, MS will support the complex table model properly.

Cd&

 

by: eirikurPosted on 2004-03-03 at 04:39:25ID: 10503951

Thank you for all your answers, I'll test them and reward the winners :)

 

by: fightbulcPosted on 2004-03-25 at 05:12:46ID: 10676583

Hi there!

I just found this topic and tried to find a solution which hasnt to much javascript in it!
So here is what i got. Try it! Works fine with IE5.01+ and Moz!

Have fun, fightbulc!

<html>
<head>
      <style type="text/css">
            body {
                  margin:0px;
                  padding:0px;
            }
      </style>
      <script type="text/javascript">
            
            function setWidth(headTable,bodyTable) {

                  tHeadObj = document.getElementById(headTable).getElementsByTagName('col');
                  tBodyObj = document.getElementById(bodyTable).getElementsByTagName('col');

                  for(i=0;i<tHeadObj.length;i++) {
                        
                        tBodyObj[i].style['width'] = tHeadObj[i].offsetWidth - (document.all ? 6:0);
                        
                  }
                  
                  window.onresize = function() { setWidth(headTable,bodyTable); }
                  
            }
            
      </script>
</head>
<body onLoad="setWidth('headTable','bodyTable')">

<table id="headTable" border="0" cellspacing="1" cellpadding="3" width="100%">

<col>
<col>
<col>

<tr>
      <td style="background:#ccc" onclick="alert(this.offsetWidth)" onmousedown="this.style['background'] = '#999'" onmouseup="this.style['background'] = '#ccc'">id</td>
      <td style="background:#ccc" onmousedown="this.style['background'] = '#999'" onmouseup="this.style['background'] = '#ccc'">firma</td>
      <td style="background:#ccc" onmousedown="this.style['background'] = '#999'" onmouseup="this.style['background'] = '#ccc'">anrede</td>
      <td style="background:#ccc" onmousedown="this.style['background'] = '#999'" onmouseup="this.style['background'] = '#ccc'">nachname</td>
</tr>
</table>

<div style="overflow:auto;height:100px;">

      <table id="bodyTable" border="0" cellspacing="1" cellpadding="3" width="100%">      

      <col>
      <col>
      <col>

      <tr>
            <td style="background:#fc0">id 1</td>
            <td style="background:#fc0">firma 1</td>
            <td style="background:#fc0">anrede 1</td>
            <td style="background:#fc0">nachname 1</td>
      </tr>
      <tr>
            <td style="background:#fc0">id 1</td>
            <td style="background:#fc0">firma 1</td>
            <td style="background:#fc0">ad adandlan ansldna ndandans daksnd 1</td>
            <td style="background:#fc0">nachname 1</td>
      </tr>
      <tr>
            <td style="background:#fc0">id 1</td>
            <td style="background:#fc0">firma 1</td>
            <td style="background:#fc0">anrede 1</td>
            <td style="background:#fc0">asdddddd asddddddddd addddddd dddddddddddddasd ad adghzhzjze 1</td>
      </tr>
      <tr>
            <td style="background:#fc0">id 1</td>
            <td style="background:#fc0">firma 1</td>
            <td style="background:#fc0">anrede 1</td>
            <td style="background:#fc0">nachname 1</td>
      </tr>
      <tr>
            <td style="background:#fc0">id 1</td>
            <td style="background:#fc0">firma 1</td>
            <td style="background:#fc0">anrede 1</td>
            <td style="background:#fc0">nachname 1</td>
      </tr>
      <tr>
            <td style="background:#fc0">id 1</td>
            <td style="background:#fc0">firma 1</td>
            <td style="background:#fc0">anrede 1</td>
            <td style="background:#fc0">nachname 1</td>
      </tr>
      </table>

</div>

</body>
</html>

 

by: skullnobrainsPosted on 2004-03-26 at 02:26:09ID: 10685757

hello, a stupid suggestion but will work on most browsers (from NN4, opera 5 or 6,  and IE5) and probably all the browsers to come in a near future.

the page is 3 elements :
- top of the page (if exists)
- headers of the table
- lines

i assume the width of a 10 cols table is the page's width

if you store the firt two in anchored div's and let the user scroll through the latter, you don't need ANY javascript for the page to work properly

if div1 is small, consider a fusion of div1 and div2, if not, consider to use a javascript to hide the first (or better : reduce it's size to 2px and use an onmouseover event to grow it again). if javascript is disabled in the client's browser, the table will still be readable.

you end up with a fully featured page wich will work on any browser in the wild apart from NN4.

note : such issues may be relevant only if the part of the page which is not in the table is small and does not need to be page-scrollable in the present nor in the future.

 

by: fightbulcPosted on 2004-03-26 at 10:26:11ID: 10689755

@skullnobrains: Can you post an example of your explaination?

I think its important to use javascript, cause of the same cell width between the header and body cells.
For me thats the big deal about the static table header.

Actually I would prefer a non javascript-version, but thats not possible, cause of the missing tbody-overflow for the IE!

Later,
fightbulc!

 

by: skullnobrainsPosted on 2004-03-26 at 13:11:15ID: 10691217

i went over the problem again, and unless u add some unsafe javascripting, it does not do the trick alright in iexplore
just for information, and since it might be usefull combined with the following link
http://javascriptkit.com/javatutors/static3.shtml

and here is the basic script for netscape

<html><body>
      <div ID="head" style="top:0;left:0;width:100%;height:25;background-color:red;position:fixed;">
      <table height="100%" bgcolor="green"><tr><td
                        onMouseOver="javascript:
                                                      document.getElementById('head').style.height=25;
                                                      document.getElementById('headers').style.top=25;"
                        onClick="javascript:document.getElementById('head').style.height=2;
                                                      document.getElementById('headers').style.top=2;">
whatever you have on top allo
</table></div>
      <script language="javascript">
document.write('<div ID="headers" style="height:20;left:0;width:100%;top:'
+document.getElementById('head').style.height+
';background-color:blue;position:fixed;">')
      </script>
table head
</div>
<br><br><br>
<table>
<script language="javascript">
for(i=0;i<70;i++)
document.write('<tr><td>line '+i);
</script>
</table>

then the simple solution for IE4 and above (as i understood from w3c site, overflow is available for divs from IE4)

<br><br><br>
<div ID="table" style="width:100%;height:100%;background-color:yellow;position:relative;overflow:scroll;">
<table>
<script language="javascript">
for(i=0;i<70;i++)
document.write('<tr><td>line '+i);
</script>
</table>
</div>

the <br>s stand for whaterver you want to be on top.

as to the title wich you could mask/unmask, the same issue applies but it does work in ie as well using frames and expression such as
<table height=\"100%\" align=\"center\" cellpadding=0 cellspacing=0 width=100%>
            <tr><td rowspan=\"2\" width=10%>
...
...
                  <td colspan=\"2\" onMouseOver=\"javascript:window.parent.document.body.rows='50,*';\"><a name=\"haut\">

in the top frame (title frame)

<a href=\"#haut\" onClick=\"window.parent.document.body.rows='2,*';\">masquer navig</a>

sorry about the '\'s everywhere but this code is part of a php page and the quotes had to be escaped

 

by: skullnobrainsPosted on 2004-03-26 at 13:13:21ID: 10691235

yups sorry i just posted seanpowells answer, apologies, i'll try to put it on lack of sleep
FAMING MESELF arghh !

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...