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
https://forums.phpfreaks.com/topic/218639-lag-with-showingnot-showing-divs/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.