Page load complete?

I'd written this message before, but forgot to click Post, just Preview and then closed my browser. So here it goes again

I have one visible frame (output) and one hidden frame (process).output contains this code (actually it doesn't - this is an example to illustrate my point)[code] function writeOut(text) { document.write(text); } writeOut("1- Starting your calculation"); parent.process.location.href = "calculate.pl?command=3+5"; // xxx writeOut("4- That's all folks. You can try again if you want"); // ... some more writeouts ...[/code]

The output in the invisible frame will be parent.output.writeOut("2- Calculating: 3 + 5"); parent.output.writeOut("3- The result is 8");

The only problem is, that the lines are output in the order 1 - 4 - 2 - 3. So obviously line 4 is printed before the (quite large) .pl-script has been completely loaded and gets the chance to print it's lines. Of course I can work around this by putting all lines from the 2nd writeOut and downwards in a separate function (footerText()) which is then called by the Perl-script after the result of the calculation has been printed, but I'd rather just replace the 'xxx' with some code that waits for the Perl-script to complete.

Hope you can help. I tried several tricks with parent.output (like .loaded and .readyState) but they all yield an 'undefined'

Comments

1. If the page has fully loaded (including images) This can be done with because the onload only fires when the page is completely loaded so all the elements are there you want to execute your functions on.

2. If the inline javascript has fully loadedThis can be done by putting alert('Script loaded'); in the top of your inline javascript as the full script must have been parsed to get this alert message.

3. If the external javascript file has fully loaded.That is the readyState thing I copied from the msdn site. Haven't used it but did the aforementioned two things; they are simple and they worked fine for my purposes.

: I'd written this message before, but forgot to click Post, just Preview and then closed my browser. So here it goes again : : I have one visible frame (output) and one hidden frame (process).: output contains this code (actually it doesn't - this is an example to illustrate my point): [code]: function writeOut(text) { document.write(text); }: writeOut("1- Starting your calculation");: parent.process.location.href = "calculate.pl?command=3+5";: // xxx: writeOut("4- That's all folks. You can try again if you want");: // ... some more writeouts ...: [/code]: : The output in the invisible frame will be : parent.output.writeOut("2- Calculating: 3 + 5"); parent.output.writeOut("3- The result is 8");: : The only problem is, that the lines are output in the order 1 - 4 - 2 - 3. So obviously line 4 is printed before the (quite large) .pl-script has been completely loaded and gets the chance to print it's lines. : Of course I can work around this by putting all lines from the 2nd writeOut and downwards in a separate function (footerText()) which is then called by the Perl-script after the result of the calculation has been printed, but I'd rather just replace the 'xxx' with some code that waits for the Perl-script to complete.: : Hope you can help. I tried several tricks with parent.output (like .loaded and .readyState) but they all yield an 'undefined':

: I'd written this message before, but forgot to click Post, just Preview and then closed my browser. So here it goes again : : I have one visible frame (output) and one hidden frame (process).: output contains this code (actually it doesn't - this is an example to illustrate my point): [code]: function writeOut(text) { document.write(text); }: writeOut("1- Starting your calculation");: parent.process.location.href = "calculate.pl?command=3+5";: // xxx: writeOut("4- That's all folks. You can try again if you want");: // ... some more writeouts ...: [/code]: : The output in the invisible frame will be : parent.output.writeOut("2- Calculating: 3 + 5"); parent.output.writeOut("3- The result is 8");: : The only problem is, that the lines are output in the order 1 - 4 - 2 - 3. So obviously line 4 is printed before the (quite large) .pl-script has been completely loaded and gets the chance to print it's lines. : Of course I can work around this by putting all lines from the 2nd writeOut and downwards in a separate function (footerText()) which is then called by the Perl-script after the result of the calculation has been printed, but I'd rather just replace the 'xxx' with some code that waits for the Perl-script to complete.: : Hope you can help. I tried several tricks with parent.output (like .loaded and .readyState) but they all yield an 'undefined':

: Hi again,: : Sorry, I forgot you worked with frames...: : Well basically this will not change the concept but as you want both frames loaded (process first and output second): : To check:: : 1. If the complete frameset has loaded (the first time only, when changing individual frames later it will not work) put this into your index page or where you define your frames:: : : : : : : 2. If the individual frame has loaded: : a, Define a global variable in the frameset page.: : var loaded = false;: : b, Put this into the output.htm:: : c, Put this into the process.htm:: : if parent.output.loaded == true: { }: : : or: : : if (typeof (parent.output.loaded != "undefined")): { process calculations here }: : : Get back to me how it works...: : Thanx,: : Lillu: : : I'd written this message before, but forgot to click Post, just Preview and then closed my browser. So here it goes again : : : : I have one visible frame (output) and one hidden frame (process).: : output contains this code (actually it doesn't - this is an example to illustrate my point): : [code]: : function writeOut(text) { document.write(text); }: : writeOut("1- Starting your calculation");: : parent.process.location.href = "calculate.pl?command=3+5";: : // xxx: : writeOut("4- That's all folks. You can try again if you want");: : // ... some more writeouts ...: : [/code]: : : : The output in the invisible frame will be : : parent.output.writeOut("2- Calculating: 3 + 5"); parent.output.writeOut("3- The result is 8");: : : : The only problem is, that the lines are output in the order 1 - 4 - 2 - 3. So obviously line 4 is printed before the (quite large) .pl-script has been completely loaded and gets the chance to print it's lines. : : Of course I can work around this by putting all lines from the 2nd writeOut and downwards in a separate function (footerText()) which is then called by the Perl-script after the result of the calculation has been printed, but I'd rather just replace the 'xxx' with some code that waits for the Perl-script to complete.: : : : Hope you can help. I tried several tricks with parent.output (like .loaded and .readyState) but they all yield an 'undefined': : : :

: Thanks, I'll try it. The 2nd one is probably what I was looking for : : : Hi again,: : : : Sorry, I forgot you worked with frames...: : : : Well basically this will not change the concept but as you want both frames loaded (process first and output second): : : : To check:: : : : 1. If the complete frameset has loaded (the first time only, when changing individual frames later it will not work) put this into your index page or where you define your frames:: : : : : : : : : : : : : : 2. If the individual frame has loaded: : : : a, Define a global variable in the frameset page.: : : : var loaded = false;: : : : b, Put this into the output.htm:: : : : c, Put this into the process.htm:: : : : if parent.output.loaded == true: : { }: : : : : : or: : : : : : if (typeof (parent.output.loaded != "undefined")): : { process calculations here }: : : : : : Get back to me how it works...: : : : Thanx,: : : : Lillu: : : : : I'd written this message before, but forgot to click Post, just Preview and then closed my browser. So here it goes again : : : : : : I have one visible frame (output) and one hidden frame (process).: : : output contains this code (actually it doesn't - this is an example to illustrate my point): : : [code]: : : function writeOut(text) { document.write(text); }: : : writeOut("1- Starting your calculation");: : : parent.process.location.href = "calculate.pl?command=3+5";: : : // xxx: : : writeOut("4- That's all folks. You can try again if you want");: : : // ... some more writeouts ...: : : [/code]: : : : : : The output in the invisible frame will be : : : parent.output.writeOut("2- Calculating: 3 + 5"); parent.output.writeOut("3- The result is 8");: : : : : : The only problem is, that the lines are output in the order 1 - 4 - 2 - 3. So obviously line 4 is printed before the (quite large) .pl-script has been completely loaded and gets the chance to print it's lines. : : : Of course I can work around this by putting all lines from the 2nd writeOut and downwards in a separate function (footerText()) which is then called by the Perl-script after the result of the calculation has been printed, but I'd rather just replace the 'xxx' with some code that waits for the Perl-script to complete.: : : : : : Hope you can help. I tried several tricks with parent.output (like .loaded and .readyState) but they all yield an 'undefined': : : : : : : : :

[b][red]This message was edited by lillu at 2003-7-21 12:47:39[/red][/b][hr]Hi,

Please forget all the code I sent so far... they're rubbish just a produce of my unreliable memory.

I decided to sit down and write this script or these errors I may have put in the previous code just gonna haunt me forever.

I tested so it works:

I changed the output.htm and output framename to output1 as I have a feeling that I managed to bump into some reserved words though I'm not sure.

Now the script waits until output1 is loaded then it sets is variable to true and sends it to its parent when it fires so we know that the output1 has surely loaded, then we get notified that the whole frameset is loaded: