Jump to content

Lag with showing/not showing divs


arbitter

Recommended Posts

Hi there,

 

I'm quite new to javascript, but I'm starting to udnerstand the things. The problem I have is simple; I have 2 div's that can be hidden or shown, with id's "sub1" and "sub2". Now, if my page is in a subcategory, that list should be shown, though this is only the case with sub1, since sub2 is a simple login-div.

This is the code:

<script type='text/javascript'> 
function togglemenu(id)
{
var object = document.getElementById(id).style

if (object.display == "none")
{
	setAllInvisible()	
	object.display = "block"
}
else if (object.display == "block")
{
	object.display = "none"
}
}

function setAllInvisible()	
{
for(var i=1; i<=2 ; i++)
{

	var object = document.getElementById("sub"+i).style;
	object.display = "none";

}

}
function checkMenu()
{
	var Qstring =  document.location.search;
sInhoud = Qstring.substring (4,11)

if(sInhoud == "groepen")
{
	var object = document.getElementById('sub1').style
	object.display = "block"

}
}
</script> 

 

When you click on a div to open a subcategory; it has eg togglemenu('sub1') with the onclick. The body onload has setAllInvisible() and checkMenu();

 

I've also integrated all this stuff in less functions, but still lags for some reason. Is it because first the server pushes all the info to your pc, and afterwards the javascript starts working?

 

For example http://www.chirotremelo.be/index2.php?fx=groepen&groep=minis; when you click on another subcategory on the left side, you'll see the div's still sliding.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.