[thelist] Javascript problem - trying to "wait"

Amazon Paulo Amazon.Paulo at Amazoniacelular.com.br
Mon Jul 15 12:23:02 CDT 2002

Hi Tom,

What about trying to use the object until it exists?

function viewerTest(){
	// just waiting
   return true;

I'm not sure if this is the best way to do that, tho... (in fact I don't
believe it is ;))

/Paulo Guedes

-----Original Message-----
From: Tom Dell'Aringa [mailto:pixelmech at yahoo.com]
Sent: Monday, July 15, 2002 1:36 PM
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()

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

      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.


var me = tom.pixelmech.webDeveloper();

Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !

More information about the thelist mailing list