Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Page load complete?

compuchipcompuchip Posts: 273Member
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

  • lillulillu Posts: 308Member
    Hi,

    To check:

    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 loaded
    This 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.




    function useStuffInSomeFile() {
    }

    if (SomeFile.readyState == "complete" ) {
    useStuffInSomeFile() {
    } else {
    SomeFile.onreadystatechange = ifComplete;
    }

    function ifComplete() {
    if (SomeFile.readyState == "complete") {
    SomeFile.onreadystatechange = null;
    useStuffInSomeFile();
    }
    }


    HTH,

    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'
    :

  • lillulillu Posts: 308Member
    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'
    :

  • compuchipcompuchip Posts: 273Member
    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'
    : :
    :
    :

  • lillulillu Posts: 308Member
    Hi,

    Oh, I made a typo ...

    of course it's
    :
    :
    :


    : 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'
    : : :
    : :
    : :
    :
    :

  • compuchipcompuchip Posts: 273Member
    lol, I'd just looked at the key of the solution and then applied it to my project. I didn't even notice the typo yet :)

    : Hi,
    :
    : Oh, I made a typo ...
    :
    : of course it's
    : :
    : :
    : :
    :
    :
    : : 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'
    : : : :
    : : :
    : : :
    : :
    : :
    :
    :

  • lillulillu Posts: 308Member
    [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:

    1. frameset page




    var loaded = false;
    if (document.loaded == "undefined")
    {
    alert('Output1 not yet loaded');
    }
    else
    {
    alert('Output1 loaded');
    }







    2. output1 page (where you output the results from the process1 calculations)




    function passValue()
    {
    parent.document.loaded = true;
    }






    3. process1 (contains no script)







    You see this is where I got when I try to code by ear hahaha...

    Good luck,

    Lillu


Sign In or Register to comment.