Link to home
Start Free TrialLog in
Avatar of MelMc
MelMcFlag for United States of America

asked on

Top Expression CSS to JS

I have an example that uses top:expression(this.offsetParent.scrollTop); in CSS that is associated with the element ID header to set a fixed scrollable header. The parent div is what actually scrolls.

I know that epxressions are bad in CSS and that they are not supported in IE8. I would like to move this to javasript.
Please do not suggest a restructure, I am using this layout for a reason (variable width, may or may not have a scrollbar, etc). I am strictly interested in moving the top expression from CSS to JS. Thanks in advance.

<div id="parent" onScroll="scroll()">
  <table>
    <thead>
      <tr id="header">
        <th></th>
      </tr>
    </thead>
    <tbody>
      <tr>
       <td></td>
      </tr>
    </tbody>
  </table>
</div>

Open in new window

Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Where is the css and function scroll ?
Did you try conditional comments and position:fixed?
Avatar of MelMc

ASKER

I wasn't going to put up all the CSS and the JS function is what I need help with...the question is just about converting the CSS function I mentioned to JS
CSS has no functions. scroll() is already a javascript function and you are using an html event to call the javscript function called scroll. Somewhere, you have to have a javascript function called "scroll" to prevent the page from crashing.

What do you want the page to do??
can you also just give the url of your page if it is out on the web? Or, could you copy and paste all of your source code here?
Avatar of MelMc

ASKER

It's not on the web. See attached.
I am looking for help writing the scroll function to eliminate the CSS expression...
#NGPTicketsLoadingImage
{
    text-align:center;
    height:100px;
    padding:50px 0 0 0;
}
.MyOpenTicketsError,
#NGPMyOpenTicketsNoTickets
{
    padding:8px 8px 0 8px;
    overflow:auto;
    overflow-x:hidden;
    margin:0 0 5px 0;
    height:auto;
}    
#NGPTicketsPanelUpdate
{
    height:145px;
    max-height:145px;
    position:relative;
    overflow:auto;
    overflow-x:hidden;
    min-width:182px;
    margin:0 0 5px 0;
}    
.NGPMyOpenTicketsTable 
{
    width:100%;
    border-collapse:collapse;
    margin-bottom:5px;
    height:auto;
    table-layout:fixed;
}
.NGPMyOpenTicketsTable a:hover
{
    text-decoration:hover;
}    
.NGPMyOpenTicketsTable>thead
{
    background-color:#F2F2F2;
    padding:0;
    margin:0;
}    
.NGPMyOpenTicketsTable .header
{
    text-align:left;
    height:16px;
    position:absolute;
    top:expression(this.offsetParent.scrollTop);
    width: 100%; 
    float: left;
    font-weight:bold;
    z-index:2;
    background-color:#F2F2F2;
}
.NGPMyOpenTicketsTable .header th
{
    background-color:#F2F2F2 !important;
    max-height:14px;
}    
.MyOpenTicketsTable-ActionRequired,
.MyOpenTicketsTable-Title,
.MyOpenTicketsTable-Date
{
    float:none;
}
#OpenTixImageHeader
{
    float: left; 
    height: 100%;
    min-width: 8px;
    max-width:16px;
}    
#OpenTixTitleHeader
{
    float:left;
    min-width:75px;
    text-align:left;
    width:auto;
}    
#OpenTixDateHeader
{
    min-width:65px;
    width:65px;
    max-width:65px;
    *+min-width:85px;
    *+width:85px;
    *+max-width:85px;
    position:relative;
    float:right;
    text-align:left;
}    
.NGPMyOpenTicketsTable .body
{
    height:auto;
    padding:20px 0 0 0;
    *+padding:36px 0 0 0;
    overflow: auto; 
    float: left; 
    width: 100%; 
    overflow-x: hidden; 
    position: relative;
}
.NGPMyOpenTicketsTable .body>tr
{
    position:relative;
    top:16px;
    z-index:1;
}
.NGPMyOpenTicketsRow
{
    height:16px;
    position:static;
    padding:0;
    width: 100%;
}
.MyOpenTicketsTable-ActionRequired
{
    min-width:8px;
}
.MyOpenTicketsTable-ActionRequired img
{
    padding:0 2px;
}    
.MyOpenTicketsTable-Title
{
    width:100%;
    min-width:75px;
}
.MyOpenTicketsTable-Date
{
    width:60px;
    min-width:60px;
    vertical-align:top;
    text-align:left;
    padding-right:8px;
}

Open in new window

<div style="" id="NGPTicketsPanelUpdate"><table width="100%" cellspacing="0" cellpadding="0" class="NGPMyOpenTicketsTable" id="MyOpenTicketsTables"><thead><tr class="header"><th style="width: 8px;" id="OpenTixImageHeader"></th><th id="OpenTixTitleHeader">Title</th><th id="OpenTixDateHeader">Opened</th></tr></thead><tbody class="body"><tr class="NGPMyOpenTicketsRow"><td class="MyOpenTicketsTable-ActionRequired"></td><td class="MyOpenTicketsTable-Title"><a title="esupport: CIO Cases are not displaying.">esupport: CIO Cases are not displaying.</a></td><td class="MyOpenTicketsTable-Date">11-Oct-10</td></tr><tr class="NGPMyOpenTicketsRow"><td class="MyOpenTicketsTable-ActionRequired"></td><td class="MyOpenTicketsTable-Title"><a title="People pages site is not saving the picture that was uploaded">People pages site is not saving the picture that was uploaded</a></td><td class="MyOpenTicketsTable-Date">11-Oct-10</td></tr></tbody></table></div>

Open in new window

Avatar of MelMc

ASKER

The scroll function would be in the div with ID NGPTicketsPanelUpdate
What exactly would you like NGPTTicketsPanelUpdate to do? What exact scroll behavior would you like??  
Avatar of MelMc

ASKER

The top:expression(this.offsetParent.scrollTop); keeps the header row in place while the div is scrolled so that you can always see the column headers. This does not work in IE8 and is not good practice, I need to move it to javascript.
If not javascript and you can handle a sroll bar at the bottom of your table body rather than the top then add a css spec for the tbody class of "body". Actually, change this <tbody class="body"> to <tbody class="body1"> as it doesn't seem like a good idea naming a class with the reserved word "body"

Then for your css
.body1
{
    overflow:scroll;
}

Nevermind, doesn't work in IE 9
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Avatar of samdan john
samdan john

How about this one.
http://pyramidions.com/