onResize event crashes IE, probably easy to a JavaScript'er

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

onResize event crashes IE, probably easy to a JavaScript'er

Post by Chris Corbyn »

Hi,

Can anyone see a better way to do this....?

I'm trying to make a table height that lives inside a table cell change dynamically if the cell height changes.

I have this code in my JS file.

Code: Select all

function doNewHeight(tableId, cellId) {
    document.getElementById(tableId).style.height = document.getElementById(cellId).offsetHeight
}
and then something like this in my html

Code: Select all

<table onResize="doNewHeight('table1','cell1')">
    <tr>
        <td id="cell1">
            <table id="table1">
                <tr>
                    <td>Bunch of pictures</td>
                </tr>
            </table>
        </td>
    </tr>
</table>
Doesn't work well in either browser (NS7 or IE6). In IE as soon as you resize the window IE stops responding. In NS7 when you resize it does its job but everytime you resize again it adds to the height so the height just keeps growing.

If anybody can see another way around this I'd be very grateful.

Thanks :-)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

tell the page to reload, instead of "adjusting" the height.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Hadn't thought of that. I'll do it but it could be bit annoying maybe for some people. Better than a buggy script though.

Thanks for the tip :-)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

NS for a long time has had a problem with the resize handler, so instead of trying to adjust the content, it's often easier to tell it to reload the page to fix itself.

It can be suggested that you may want to rethink your design if it requires these measures though. ;)
Post Reply