On Mar 2, 1:00 pm, "MAB" <mbeck...@gmail.comwrote:
Quote:
On Mar 2, 9:56 am, "Mister Joe" <mrjoefri...@gmail.comwrote:
>
>
>
>
> Quote: |
On Mar 1, 6:00 pm, "MAB" <mbeck...@gmail.comwrote:
| > Quote: Quote: |
I have the following function:
| | > Quote: Quote:
function doStuff(str) {
var DataSite="test1a.asp?q="+str;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = DataSite;
document.getElementsByTagName('head')[0].appendChild(script);
var x = doMoreStuff();
}
| | > Quote: Quote:
The function loads an asp page into memory. I am looking for a cross
browser solution to test to see if the page is fully loaded before
doMoreStuff is called. Can anyone offer some code or point me in the
right direction? Thanks.
| | > Quote:
I'm guessing that either doMoreStuff or something that doeMoreStuff
needs is in the script you are trying to load. You may want to try
using a try catch statement. That way if you get an exception b/c you
are trying to access an element that has not been created (or a
similar exception) in the catch you can set the timeout for 2 seconds
(or whatever you think is best).
| >
Thanks for the response. the doMoreStuff function process the data
from the page that was loaded. Unfortunately, it tries to do it
before the page finishes loading. As a result, I get no data the
first time it is run and I remain one iteration behind the data
generation.
>
I would prefer not to use a timeout as I will simpley have to guess
how long it will take to run.
>
Other ideas?- Hide quoted text -
>
- Show quoted text -
|
You're not going to get any kind of notification event, if that's what
you're looking for. You could try something like:
function doMoreStuffWhenReady() {
try {
doMoreStuff();
}
catch(e) {
doMoreStuffWhenReady();
}
}
Then from your function call doMoreStuffWhenReady() instead of
doMoreStuff. The idea is that it will continue to try to doMoreStuff
until there are no exceptions.
I have NO idea what kind of processor usage implications this would
have. But test it.