#1
  1. a lazy guy
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    Hong Kong
    Posts
    99
    Rep Power
    14

    Javascript: fixed position of a link


    I have a HTML Table

    eg.
    <TABLE>
    <TR>
    <TD>
    <a href="xxx"><img src="link.gif"/></a>
    </TD>
    <TD>
    ..
    ..
    this cell contains a very very very long text,
    that use up 3 vertical window size.
    ..
    ..
    </TD>
    </TR>
    </TABLE>


    In the above HTML, how can I put the first cell(the link) always on the screen when a user scrolling down the window to read the text in the second cell?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2001
    Posts
    765
    Rep Power
    13
    <html>
    <head>
    <title>untitled</title>
    <style type="text/css">

    #fixedcell {
    position: relative;
    }

    </style>
    <script type="text/javascript" language="JavaScript">

    function mrfixit() {
    var fc = document.getElementById('fixedcell');
    fc_top = fc.offsetParent.offsetTop;
    fc.style.top = document.body.scrollTop + fc_top;
    }
    onscroll = mrfixit;

    </script>
    </head>
    <body>
    <table width="100%"><tr valign="top"><td>
    <span id="fixedcell">
    <a href="#"><img border="0" src="http://forums.devshed.com/images/devtitle.gif"></a></span></td>
    <td style="font:200 600px 'Times New Roman';text-align:center;background:coral;">
    *<br>*<br>*</td></tr></table>
    </body>
    </html>
    Last edited by mrrichardfeder; April 28th, 2002 at 06:35 PM.
  4. #3
  5. a lazy guy
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    Hong Kong
    Posts
    99
    Rep Power
    14

    thanks


    mrrichardfeder,

    it works.
    Thanks a lot for your help

IMN logo majestic logo threadwatch logo seochat tools logo