Speed up iteration over options of a SELECT element in MSIE

Problem: An application opens a new browser window in which the user makes some choice. That choice is used to select an OPTION within a SELECT element (combo box, list) in another browser window. The target SELECT contains many (thousands) of values. Because options are not sorted by value, finding the correct one using JavaScript requires a linear loop. This loop takes a very long time (8 seconds), especially in Internet Explorer (version 6 and 7).

Solution: Avoid inter-frame access to the options list of a SELECT element. Instead, define the resource hungry loop within the same frame where the SELECT element is contained. This brings the execution time into the milliseconds range.

I suspect that inter-frame communication in JavaScript triggers some sort of security/access control checks within the browser, accounting for the slowdowns.

No comments:

Post a Comment