JavaScipt Freezes Browser While Function Is Executing
<p>I'm developing a web page which acts as a database querying tool. The database table is quite large (26MB) in size so I have decided to store each row from the table as a JavaScipt object in an array (to prevent continuous transmission of data).</p>

<p>The page loads with no problems. The trouble begins when I begin to 'query' the array of JavaScript objects. </p>

<p>The function below executes on the keyup event of a HTML text box. When this function executes it causes the browser to become unresponsive and freeze temporarily until the function has finished executing. I have previously read on the use of the setTimeout() and setInterval() functions to overcome this problem but I have been unable to adapt these to my own problem. Any help is much appreciated. Thanks in advance.</p>

<pre><code>function searchStock() {
    results.innerHTML = "Stock Loading..."; //results is a div tag where query results are displayed
    var stringTyped = nameTextBox.value;
    var resultString = "&lt;table&gt;";
    for (var z = 0; z &lt; stock.length; z++) //stock is the array of objects to be searched
    {
        if (stringTyped == "") {
            resultString = resultString + rows[z]; //rows is an array consisting of how each item in the stock is displayed
        }
        else {
            if (stock[z].Stock_Name.indexOf(stringTyped) != -1) {
                resultString = resultString + rows[z];
            }
        }
    }
    resultString = resultString + "&lt;/table&gt;";
    results.innerHTML = resultString;
}​
</code></pre>
