homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Javascript Memory Leakage
My sitemap/menu may be unusable

10+ Year Member

Msg#: 544 posted 10:07 pm on Aug 26, 2003 (gmt 0)

For our company intranet I'm looking at a sitemap as a series of nested ULs. Up to 4 levels deep. I've used CSS to style and hide them.
A mouseover on LI tags calls menutoggle to reveal the lower braches be altering visibilty of the UL tag and alters the appearance of the LI tag. Especially with larger branches there appears to be increased memory use at each change. Can anyone spot anything in my Javascript I could add/remove to prevent memory leakage?
menuhide=new Array()
prevmenu=new Array('','','','','')
function menutoggle(menu,level) {
if (document.getElementById('s' + menu)) {
show= document.getElementById('s' + menu).style.display
if (prevmenu[level]!="") {
document.getElementById('s' + prevmenu[level]).style.display="none"
document.getElementById('m' + prevmenu[level]).style.backgroundImage='url("blue.jpg")'
document.getElementById('s' + menu).style.display="block"
document.getElementById('m' + menu).style.backgroundImage='url("red.jpg")'



10+ Year Member

Msg#: 544 posted 10:34 pm on Aug 26, 2003 (gmt 0)

I see two things you could clean up, though I doubt either is causing your problem..

1. It doesn't appear you ever use this variable show:
show= document.getElementById('s' + menu).style.display
If so, you could delete that line.

2. You could put the string (?) prevmenu[level] into a variable, so you don't have to look it up each time.

Good luck..


WebmasterWorld Senior Member 10+ Year Member

Msg#: 544 posted 3:26 am on Aug 27, 2003 (gmt 0)

// the array length can be undefined on construction,
// if you want to specify a length use a number,
// e.g., Array(4)
prevmenu=new Array();
function menutoggle(menu,level) {
if (document.getElementById('s' + menu)) {
var shown=document.getElementById('s' + menu).style;
if (shown.display!= "none") {
// no need to set the image since you are hiding it
else {

If that still doesn't help, you can sticky me the URL and I'll see if I can spot anything else in the code that might be causing excess memory usage. Fours eyes are better than two. :)


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved