Tags: | Posted by Admin on 3/4/2008 3:08 AM | Comments (0)

Firefox and Safari seem to be destroying and recreating a Silverlight object when it's inside of a control that has its style set to "display:none".  It doesn't do this when visibility is used instead of display. 

Here's a working example.  I fire an alert in the silverlight object's onload method.  In IE, the alert doesn't pop up when you switch display back to '', but in Firefox and Safari, it does.

image
Example at airportwait.com (my demo site)

I'm sure the next question you're going to ask is why I don't just use visibility... Well, I'm using the ajax tabcontainer control, and it's using display to show/hide tabs.  More importantly, it just doesn't seem right.  It might be ok when your silverlight control is static, but I'm using javascript to initialize a photoviewer I wrote, and don't want it to have to lose the viewer's place.

Anyway, does anyone know why this is?  Is it some kind of standard to destroy objects when their parent is set to display:none?  Is there a workaround?

John

ps.  And dang it all, I thought Silverlight was the end of browser compatibility issues ;).  I could also go into why different browsers fire different silverlight events at different times (onresize, do you hear me?), but I'll leave that alone.