[thelist] Javascript problem - trying to "wait"

Tom Dell'Aringa pixelmech at yahoo.com
Mon Jul 15 13:08:19 CDT 2002


Ken, that seems to make sense except, what I am checking for -
if(parent.frames["graphicView"].document.getElementById("va_3d_vml_viewer"))
- happens in another document in another frame. Nor can I move that
code to the page I am working with...

So did I miss the point or did you not notice that... :)

Tom

--- Ken Kogler <ken.kogler at cph.org> wrote:
> If you put a <script src="/something.js"> tag WITHIN the
> <body></body> tags
> on your page, the browser will be forced to fully load the contents
> of that
> .js file before executing the <body onload="init();"> statement.
>
> Take whatever causes A to happen, and more it into a .js file, then
> stick
> the call for that .js into the <body>, not the <head>. The init()
> function
> can remain in the head of that file, since it's not called until
> everything
> in the <body> loads (hence the tern onLoad...)
>
> HTH!
>
> --ken
>
> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]On Behalf Of Tom Dell'Aringa
> Sent: Monday, July 15, 2002 11:36 AM
> To: thelist at lists.evolt.org
> Subject: [thelist] Javascript problem - trying to "wait"
>
>
> Hi All,
>
> I've got a tricky javascript issue. I have action B happening on
> page
> load in an init() function. In order for B to happen, A must be
> loaded first (to avoid a object required error). I have been
> experimenting with setInterval() to accomplish this. I have the
> problem KIND OF solved, but as our CAD developer said, its a bad
> solution. Here is some code:
>
> Function 1: Test to see if object has loaded
> ----------------------------------------------
> function viewerTest()
> {
>
>
if(parent.frames["graphicView"].document.getElementById("va_3d_vml_viewer"))
>    {
>       clearInterval(checkViewer);
>       return true;
>    }
>    return false;
> }
> ----------------------------------------------
>
> So when this function is called it either returns TRUE or FALSE,
> depending on if the viewer is there. makes sense. Here's the other
> part, inside the init() function:
>
> ----------------------------------------------
>
> // wait for viewer to be there
>
> checkViewer = setInterval("viewerTest()", 50);
>
> while(!viewerTest())
>    {
>       checkViewer;  //waiting for the viewer to continue.
>    }
> ----------------------------------------------
>
> Now, this seems to work, but here's the issue - its an overload on
> server resources (which in the app I am working on is a BIG issue.)
>
> I set the interval to the var checkViewer. This means the interval
> starts checking the viewerTest() function every 50 milliseconds
> until
> it finds it and is cleared there.
>
> But, during my "wait" part in the while loop, I am ALSO checking
> against viewerTest(), and during the while loop the check is
> CONSTANT
> until it finds it. This is duplicating the process seemingly.
>
> Lastly, I call the variable checkViewer (the interval) inside the
> while loop. Why? If I don't, its an endless loop error. Crash.
> We've
> tried merely using the while loop, checking against the
> viewerTest()
> function. You would think that would work, but often we get an
> endless loop crash.
>
> This is a real stinker, any input is appreciated.
>
> Tom
>
>
>
> =====
> var me = tom.pixelmech.webDeveloper();
> http://www.pixelmech.com/
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Autos - Get free new car price quotes
> http://autos.yahoo.com
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !


=====
var me = tom.pixelmech.webDeveloper();
http://www.pixelmech.com/

__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com



More information about the thelist mailing list