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>
cotton9Asked:
Who is Participating?
 
ClickCentricConnect With a Mentor Commented:
Actually, you're getting a race condition.  Use this instead:

<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 type="text/javascript">
WindowMngr('win16610479', WindowMngr.CLOSEABLE|WindowMngr.DRAGABLE|WindowMngr.RESIZEABLE|WindowMngr.VERTICAL_SCROLL);
setTimeout("WindowMngr('win16610479')",100);
</script>
                               
</body>
</html>

The short timeout should be enough to give the first call time to set up the parameters.  Worked when I tested it.
0
 
ClickCentricCommented:
You've tried changing:

<body>

to

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

And it didn't work?
0
 
ClickCentricCommented:
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');">
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
cotton9Author Commented:
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.  

0
 
cotton9Author Commented:
Darn those race conditions!  

Thanks for the help ClickCentric
0
 
ClickCentricCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.