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.

<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 ( {; 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];}}


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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])

That's all


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
juststeveAuthor Commented:
sorry it took awhile thankx for the answer.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.