Friday, December 26, 2008

Silverlight 2 and Opera

To make the previous example also work on Opera I would have to

  • Set the data on the object to be "data:application/x-silverlight-2," to get it to work at all
  • to restore the effect of transparency remove the <param name="windowless" value="true" />
  • set an opaque value rather than <param name="background" value="#00000000" /> matching the page background colour
  • manually tile a matching background image and set background image brush with Stretch="None" to match any page background image

In particular, there seems to be no obvious way to get at the parameter set of the object from JavaScript via a DOM look-up on the <object> tag, otherwise I would have done some jQuery magic via browser sniffing instead.

Bug in my jQuery usage. BRB

You can do something like

$(document).ready(function(){
var obj = $('#silverlightControlHost');
var param = obj[0].firstChild.nextSibling.firstChild.nextSibling;
param['value'] = !($.browser.opera);
if(!$.browser.opera)
{
param = param.nextSibling.nextSibling;
param['value'] = '#00000000';
}
});
view raw gistfile1.js hosted with ❤ by GitHub

but once you've tiled with an opaque image, there's no effect (even if this substitution were in fact in time to be useful).

Sample here.

I guess such customization would be possible via the silverlight.js file; however that needs tome work of its own to fix up to provise silverlight 2 data types.

No comments :