I have a web page with a vbscript section that looks like

Sub Window_Onload()
msgbox("Here")
call getprojmonths(intProjNum,0)
End Sub

getprojmonths is a javascript function being called from a vbscript
sub to provide ajax functionality and yes, it works.

Here's the odd part: if I take out the msgbox the call does not get
made. Furthermore, if I put another vbscript statement between the
msgbox and js call it won't work; the js call must immediately follow
the msgbox.

I'm working on rewriting the js as vbscript but I am still curious why
I have to execute a msgbox to get the js call to work.

I'd love to hear why it behaves this way if anyone knows.

Re: Help needed: Very odd VB Script behavior by mr_unreliable

mr_unreliable
Thu Sep 06 10:16:34 PDT 2007

es330td wrote:
> I have a web page with a vbscript section that looks like
>
> Sub Window_Onload()
> msgbox("Here")
> call getprojmonths(intProjNum,0)
> End Sub
>
> getprojmonths is a javascript function being called from a vbscript
> sub to provide ajax functionality and yes, it works.
>
> Here's the odd part: if I take out the msgbox the call does not get
> made.

hi es330,

I can't answer your question directly, but I have a suspicion,
which has to do with IE's firing the "OnLoad" event.

In my experience (if not anybody else's) the onload event can
sometimes fire before the document is fully loaded. It has
been recommended here (this ng) that one can avoid any problems
that this can cause by using the document "ReadyState" property
instead of onload. Here is some pseudo-code:

Const READYSTATE_COMPLETE = 4

if IE.document.ReadyState = READYSTATE_COMPLETE then
continue with your script
else
wait-a-bit and try readystate again...
End If

Let's say I'm right. If the document isn't fully loaded,
then maybe the complete functionality is not ready, and
so IE just goes on its merry way.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)