IE’s retarded script behavior

Just got bitten by this IE 6 bug. I had an external script which I included. It bound a click on an element to a function which toggles the visibility of another element.

For some reason, events were being delivered twice when I clicked the toggle element. Well, it turns out that:

  • My <script> element was a child of the element whose visibility was toggled.
  • Internet Explorer runs scripts in elements whose visibility is changed to make them visible, even though the script was already run at page load-time

Moving my <script> outside the toggled div solved the problem. But who knew that IE would re-run scripts when CSS was changed on their parent elements?

Leave a Reply