How can I force reflow after DHTML change in IE7?

后端 未结 2 569
伪装坚强ぢ
伪装坚强ぢ 2021-02-02 14:07

I have a page where the user can dynamically add file upload boxes. Adding the boxes changes the height of the div they are in, but certain elements of the div below it stay in

2条回答
  •  渐次进展
    2021-02-02 14:53

    Try:

    element.className = element.className;
    

    on the modified div (or possibly its parent, or even a more remote ancestor, depending on various factors such as relatively-positioned containment).

    As the className has been assigned a value IE will reflow and repaint that portion of the page in case the CSS affecting that element has changed. Luckily, it isn't optimised to check if the className value actually changed from its previous value, so the above will trigger the reflow without breaking anything else.

    I did find one occasion when this fixed IE6 but broke IE7, but try it and see if it works for you.

提交回复
热议问题