Click to See Complete Forum and Search --> : memory leakage with show & hide


zbluebirdz
04-14-2003, 05:36 AM
Hi,

Is there any problems in showing/hiding form objects in IE?

e.g., I have a number of "sections" in the page and the user clicks on a button to "expand" a section to fill out some fields and then expand another one ... the user might then "collapse" a section that is already expanded.

I'm using div tags to make the sections and the following code to show/hide the divs.

function hideObj( obj )
{
tObj = eval ( "document.all." + obj + ".style" ) ;
if ( tObj.display != "none" )
{
tObj.display = "none" ;
}
}

function showObj( obj )
{
tObj = eval ( "document.all." + obj + ".style" ) ;
if ( tObj.display != "" )
{
tObj.display = "" ;
}
}


After using the showObj & hideObj a couple of times, the fields start to "disappear" from the page and soon IE runs out of memory. Is there a solution to this?

gil davis
04-14-2003, 05:44 AM
You could try this alternative:function hideObj(obj) {
if (document.getElementById)
{document.getElementById(obj).style.display = "none";}
else
{if (document.all)
{document.all[obj].style.display = "none";}
}
}

function showObj(obj) {
if (document.getElementById)
{document.getElementById(obj).style.display = "block";}
else
{if (document.all)
{document.all[obj].style.display = "block";}
}
}There is an additional benefit: your page will work in NS 6+ and Mozilla.