I am using flash and javascript in a page together and thanks to some previous help here, they are speaking very nicely to each other.

One of my javascript pages is a search result page that has an .onload event that loops through a passed array and display the results. When I display the results as a bulleted list using .innerHTML, the page displays instantly. But my bosses prefer the results in a table. IE does not like having <tr><td></td></tr> in the innerHTML so I am using some DOM along with innerHTML to display the results.

This new method can cause a 3-4 second pause when displaying around 1000 results. This pause is fine, but I want to notify users that the code is doing something and they don't have to press the search button again.

So I setup a 'loading' variable in the js and am having flash display that every frame right now (later it will cue a loading please wait screen, this is for testing). 1 is supposed to mean the page is loading, but not fully loaded yet. 0 means the page has fully loaded.

I get undefined before the page is loaded, as expected. When I click search, the variable stays undefined until the end of the 3-4 second pause when it jumps to 0. If it ever has a value of 1, it is so fast I cant see it flicker at 30 fps.

Here is my js code... Is there a better place to put loading=1 so that it gets set immediately as the page is called and not after the page has fully loaded?

PHP Code:
<script language="JavaScript">
    var 
flash;
    var 
loading;
    
loading 1;  // loading value checked by javascript in another frame
    
window.onload = function() {
        
flash top._menu.document.getElementById("flashObject");

        var 
flashInfo flash.getFlashInfo();

        
//setup headers
        
var resultTable document.getElementById("searchresults").tBodies[0];
        var 
newRow resultTable.insertRow(-1);
        for (var 
k in flashInfo[0]){
            if(
!= "link"){
            var 
newCell1 newRow.insertCell(-1);
            
newCell1.innerHTML "<p align='center'><b>"k.toUpperCase() + "</b></p>";
            }
        }

        
//fill in all data
        
for (var k in flashInfo) {
            var 
resultTable document.getElementById("searchresults").tBodies[0];
            var 
newRow resultTable.insertRow(-1);
            for (var 
l in flashInfo[k]){
                if(
!= "link"){
                    var 
newCell newRow.insertCell(-1);
                    if (
flashInfo[k][l] != "Unk"){
                        
newCell.innerHTML "<a href='" flashInfo[k].link "' target='_content'>" flashInfo[k][l] + "</a>";
                    } else {
                        
newCell.innerHTML "-";
                    }
                }
            }
        }
        
loading 0;
    }
</script> 
Thank you for any help/suggestions. I COULD just assume the JS page opened properly and wait for the loading=0 return in flash, but I was hoping to use this to kill 2 birds with one stone and confirm that the page is opening properly right away instead of having a timeout of 10 seconds or whatever in flash. Timeouts scare me anyway because our network can get pretty slow.