Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sfhover for menus. Initially, there is a delay

Status
Not open for further replies.

ForumKid

MIS
Dec 21, 2001
122
US
I am using the below code for drop down menus. It works perfectly The only problem I have is when someone comes to our page initially or they refresh the page, it takes a few seconds..sometimes 2 seconds..sometimes 10 seconds for the mouseover to work. Does anyone know where that setting is????

<!--//--><![CDATA[//><!--
sfHover = function() {
var sfEls = document.getElementById('MainLevel').getElementsByTagName('LI');
for (var i=0; i<sfEls.length; i++) {
sfEls.onmouseover=function() {
this.className+=' sfhover';
}
sfEls.onmouseout=function() {
this.className=this.className.replace(new RegExp(' sfhover\\b'), '');
}
}
}
if (window.attachEvent) window.attachEvent('onload', sfHover);
//--><!]]></script>
 
It's right in your code:
Code:
if (window.attachEvent) window.attachEvent('onload', sfHover);

The page waits until it is completely loaded. Once it is done loading it attaches the mouseover events. If the page takes a long time to load (i.e. lots of pictures and stuff) then it will take a long time for the mouseover events to be applied. You're really at the mercy of the client's network connection and speed of computer. It's not just some switch you can flip. Now.... there may be a possibility that you could optimize some of your code to speed up the load time, but that's a different question for a different thread.

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top