Javascript: how to really prove a frame is loaded? Global variables not working?
<p>I've been fooling around with developing an IETMs interface (Interactive Electronic Technical Manual - like an interactive parts catalogue) to display the data live from an existing Access database. The idea is to be able to run this interface on a network hosted intranet with straight HTML, plain Javascript, VBScript &amp; ActiveX objects, so that it doesn't require IIS etc to run ASP or PHP etc (I don't want to involve corporate IT for the IIS).</p>

<p>All is going pretty well, &amp; I'm impressed with the setup except for a few minor things - checking if a frame is loaded, &amp; global variables.</p>

<p>My setup is a HTML page hosting 5 frames with each containing an empty  (which gets the page written to it dynamically), but I need to ensure all frames are loaded before getting into the heavy stuff (which Javascript is handling brilliantly!). But I'm finding that Javascript sux at truly detecting if a frame is loaded (someone please prove me wrong!). I have all 5 frames call a function fnInitialiseIfReady(), then if I could either successfully test if all frames are loaded, or if I could globally count if this function has been called 5 times, I can proceed with confidence &amp; call my function fnInitialise(). But unfortunately neither is working for me. :(</p>

<p>From tireless internet searches, I've tried the 'frames always load in order' theory, &amp; that is simply not correct. I have set up a test with the frames calling a function passing their name as a parameter, &amp; each time the frames load in a different order every time. It is totally random. Note: I proved this by having the first 4 frames call a certain function(which contains an alert() line showing the frame name parameter passed), &amp; having the last frame call a different function (which contains an alert("all are loaded!") line). The "all are loaded!" does not always appear last.</p>

<p>I've also tried the '.frames["FrameName"].document.loaded' approach, &amp; it ALWAYS returns 'undefined' for every frame. Am I doing something wrong here?</p>

<p>I've also tried the '.frames["FrameName"].window.location.href' approach &amp; it ALWAYS returns the html filename regardless of whether that page has loaded or not, so it is not an indicator of loading completion.</p>

<p>I've also tried the '.frames["FrameName"].document.location' approach &amp; it's ALWAYS the same as the '.window.location.href' approach.</p>

<p>Also, I'm finding Javascript will not hold global variables for me at all. I don't know if it's a combination of multiple frames &amp; using Javascript &amp; VBScript together, but global variables just do not hold a value at all. Local variables (within functions) are fine. Any ideas? I don't have many globals, so I'm thinking of using a cookie. A valid Solution?</p>

<p>BTW, the reason for also using VBScript is that it accesses the ActiveX controls by default, &amp; being a corporate intranet app I can guarantee MSIE usage.</p>

<p>It's frustrating because if I can solve these 2 relatively minor issues, then I'm super impressed with the robustness of this Javascript/VBScript approach. By leveraging each of their strengths, it's crunching the data just as quickly as the VB, C#, &amp; C++ programs I've written for this particular dataset. I'm impressed! :)</p>

<p>Thanks in advance,</p>

<p>Dave Lock.</p>
