Tuesday, May 18, 2010

Dealing with browser repaints

Recently i wanted to hide a silverlight plugin content and display some html content in its place. As you might be knowing, plug-in content redrawing is a known problem all the time. So i decided to put both the contents in a table row and dynamically set the row height.



document.getElementById("Showcase").style.height = '0px';
               and
document.getElementById("Showcase").style.height = '500px';

Problem later i found that it works fine with IE, FF, Chrome but in opera its a problem. It requires you to scroll once for redrawing the content.  So you will still see the flash/Silverlight content and the new html content, untill you scroll.

This has been discussed in couple of places, but could not find any solution. So, i decided to put a scroll automatically. I tried scrolling it with 1 px, it worked!!! So i tried with 0px.... and ... it worked too!!!!

window.scroll(0, 0);
Try and let me know if it fixes your repain problem too...