SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    May 2003
    Location
    here
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dynamic height in NS 4.76

    I need to be able to resize a tables cell dynamically, I don't want to reload the page ( the cell contains a flash movie that gets resized dynamically).

    For IE and NS7 I call this function everytime the flash movie changes:

    function reSize(newHeight){
    if(document.getElementById && !(document.all)) {
    document.getElementById('tar').height = newHeight;
    }
    else if(document.all) {
    document.all.tar.style.height = newHeight;
    }
    }
    //"tar" is the id of the cell I need to resize
    Works fine.

    But I need to be compatible with netscape 4.76 which dosen't support the getElementByID.

    any ideas????

    Cheers

  2. #2
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't have NS4 installed anymore so I can't help you with testing but you may want to try to encapsulate the content of that cell in a layer for Netscape (actually a Netscape Layer) and accessing the clip properties of that layer to change the height.

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Forget about messing with table cells in Navigator; the only way to do this is to have the entire table inside a layer and re-write that, including the desired changes. The rest of the page will not be re-rendered, so you'll need to keep any other content away from the table.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>untitled</title>
    <script type="text/javascript" language="javascript">
    
    function setCellHeight(el_id, new_height) {
    var el = document.getElementById ? document.getElementById(el_id) :
    document.all ? document.all(el_id) : 
    document.layers ? document[el_id + 'layer'] : null;
    if (el && el.style) el.style.height = new_height;
    else if (document.layers) {
    var tableHTML = '<table><tr><td width="200" height="100" bgcolor="olive">&nbsp;</td>';
    tableHTML += '<td width="200" height="100" bgcolor="darkorange">&nbsp;</td></tr><tr>';
    tableHTML += '<td width="200" height="' + new_height + '" bgcolor="tan">&nbsp;</td>';
    tableHTML += '<td width="200" height="100" bgcolor="silver">&nbsp;</td></tr></table>';
    el.document.write(tableHTML);
    el.document.close();
    }
    }
    
    </script>
    </head>
    <body>
    <a href="javascript&#58;void setCellHeight('tar',200)">expand tan</a><br>
    <layer id="tarlayer">
    <table>
    <tr>
    <td width="200" height="100" bgcolor="olive">&nbsp;</td>
    <td width="200" height="100" bgcolor="darkorange">&nbsp;</td>
    </tr><tr>
    <td id="tar" width="200" height="100" bgcolor="tan">&nbsp;</td>
    <td width="200" height="100" bgcolor="silver">&nbsp;</td>
    </tr>
    </table>
    </layer>
    </body>
    </html>
    Last edited by adios; May 28, 2003 at 09:31.

  4. #4
    SitePoint Member
    Join Date
    May 2003
    Location
    here
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    adios that code works great.

    But of course, if i resize the cell to a height greater than the visible screen, NS4.76 won't give me a scroll bar.

    I have tried adding the style overflow:auto but that dosen't work. I am searching for a way ot force the scroll bar.

    I can get a scroll bar by setting the window.innerHeight to itself + 1 then itself - 1, but then the flash movie that I am changing the size of in the table cell disapears.

    any ideas??

  5. #5
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Add this to the function:

    .......
    el.document.close();
    document.height = el.pageY + el.clip.height;
    }

    ...more useless crap

  6. #6
    SitePoint Member
    Join Date
    May 2003
    Location
    here
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You ROCK! That is awesome.

    Cheers!

  7. #7
    SitePoint Member
    Join Date
    May 2003
    Location
    here
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Final Note: The el.document.close(); was making the flash movie I was using in this cell go blank if the window was resized. By removing it it all works wonderfully.

    Many Thanks adios!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •