Link to home
Start Free TrialLog in
Avatar of cotton9
cotton9

asked on

OnClick works, but not OnLoad?

I'm trying to run the following script onLoad instead of onClick, but it does nothing onLoad.  The script generates a css popup window onClick by changing the visibility of the div.  

How can I get it to run onload?

(I've linked to the script if it helps - 3rd party)


<html>
<head>
<script src="http://www.litotes.demon.co.uk/js_info/scripts/WindowMngr.js" type="text/javascript"></script>
</head>
<body>

<a href="#" onclick="return WindowMngr('win16610479');">Click Here</a>


<!--Popup Window Code-->
<div id="win16610479">
  <h3><a>Title</a></h3>
  <div><div><div><p>Text</p></div></div></div>
</div>
<!--End Popup Window Code-->

<script>WindowMngr('win16610479', WindowMngr.CLOSEABLE|WindowMngr.DRAGABLE|WindowMngr.RESIZEABLE|WindowMngr.VERTICAL_SCROLL);</script>
                                     
</body>
</html>
Avatar of ClickCentric
ClickCentric

You've tried changing:

<body>

to

<body onload="WindowMngr('win16610479', WindowMngr.CLOSEABLE|WindowMngr.DRAGABLE|WindowMngr.RESIZEABLE|WindowMngr.VERTICAL_SCROLL);">

And it didn't work?
Oh wait, on a closer look, you weren't running onload, you were running it inline.  

And I think I see where the problem is.  Change what I have above to:

<body onload="WindowMngr('win16610479', WindowMngr.CLOSEABLE|WindowMngr.DRAGABLE|WindowMngr.RESIZEABLE|WindowMngr.VERTICAL_SCROLL);WindowMngr('win16610479');">
Avatar of cotton9

ASKER

Thanks for the help, but that isn't working either.  Nothing happened.

The code above is actually fully functional (with onclick) if you want to see the desired effect or test it out.  

ASKER CERTIFIED SOLUTION
Avatar of ClickCentric
ClickCentric

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cotton9

ASKER

Darn those race conditions!  

Thanks for the help ClickCentric
Not a problem.   Something seemed fishy which caused me to try it out for myself and I knew the coding was right and no errors were getting thrown, so on a hunch I tried the timeout and that did it.  You may want to play with the value a bit.  It actually works for me with the timeout set to 1 instead of 100, but I have a pretty fast computer.  You have to plan for the people who still have the pentium 90's out there. :P