Onload: Force 2nd function to wait.

I'm firing 2 functions from the page onLoad event. They are Dreamweaver functions and both work correctly - I'm looking for code to force the 2nd function to wait for the completion of the first and then execute.

1st function is a 'preload images', second 'hides' a layer - effect is a black screen (layer) hides the main page until all images are present and ready for rollovers or instant viewing.

http://www.juststeve.com/nportfolio.htm


<body onLoad="MM_preloadImages([arglist here]); MM_showHideLayers('Layer5','','hide') ">

For sake of completeness here's the function code but again, functions work ... just need to make MM_showHideLayers wait.

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

/* Functions that handle preload. */
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}

juststeveAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
xabiConnect With a Mentor Commented:
Hi there:

Try this:

change your body tag into this one:

<body onLoad="init()">

and add this new function

function init() {
  MM_preloadImages([arglist here])
  MM_showHideLayers('Layer5','','hide')
}

That's all

xabi
0
 
juststeveAuthor Commented:
sorry it took awhile thankx for the answer.
0
All Courses

From novice to tech pro — start learning today.