0

in my javascript I load up an array based upon the HTML which has already produced. In Firefox this works perfectly, but in Internet Explorer 7 the page hangs for approximately several minutes.

I can't see why it takes so long to do something Firefox has no problem with?

ImageHTMLContainer just acts like a dictionary storing inner html.

var ImageHTMLContainer = [];

addLoadEvent(init);

function init() {

    var NumOfRows = parseInt(DID("NumRows").innerHTML);
    var NumOfCols = parseInt(DID("NumCols").innerHTML);
    var i;
    var j;

    for (i = 0; i < NumOfRows; i++) {
        ImageHTMLContainer["Row" + i.toString()] = DID("Row" + i).innerHTML;
        for (j = 0; j < NumOfCols; j++) {
            ImageHTMLContainer["Row" + i.toString() + "Col" + j.toString()] = DID("Row" + i + "Col" + j).innerHTML;
        }
    }
}
5
  • 1
    You should post the code for the DID function too. Commented Mar 15, 2011 at 15:15
  • How many rows and columns are there? Commented Mar 15, 2011 at 15:16
  • Sorry DID just returns the document.getelementbyid Commented Mar 15, 2011 at 15:17
  • There are 400 rows (although this can vary) and 39 columns (eeek) Commented Mar 15, 2011 at 15:19
  • Aren't IE users used to slow and non-responding pages? Commented Mar 15, 2011 at 15:44

1 Answer 1

1

ie7's js engine is a lot older and slower than the one in firefox.

You have a loop within a loop that reads innerHTML - don't do that, it is probably the very least efficient way you can do what you are doing.

Have you considered loading your data via xml or json instead of initializing your javascript data via the rendered DOM?

Sign up to request clarification or add additional context in comments.

1 Comment

Could you elaborate on this? A table is being produced from SQL and i'm loading the inner html into JS to enable sorting. I load the data into JS because there are columns containing images etc, so its easier just to swap the inner html of the rows when re-sorting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.