Silverlight 2 & CreateSilverlight()
Current Silverlight 2 Beta by default doesn't using silverlight.js/CreateSilverlight() functionality we used to add Silverlight in Alpha version, but Silverlight directly created on page as object:
1: <div id="silverlightControlHost">
2: <object data="data:application/x-silverlight," type="application/x-silverlight-2-b1" width="100%" height="100%">
3: <param name="source" value="SilverlightApplication4.xap"/>
4: <param name="onerror" value="onSilverlightError" />
5: <param name="background" value="white" />
6:
7: <a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;">
8: <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
9: </a>
10: </object>
11: <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
12: </div>
What to do, when we want to control more precisely the object creation, fine tune some properties or use single point of creation for multiple Silverlight components in single page?
Well, the good news, that silverlight.js is still exists (could be found in Silverlight SDK directory "%ProgramFiles%\Microsoft SDKs\Silverlight\v2.0\Tools"), and could be used to create our own createSilverlight() functions... Here is my example of such a function:
1: //Parameters:
2: //src - source xap file
3: //elm - host element Id
4: //width, height - control width/height (could be in %)
5: //htmlAccess - allow control to interact with HTML. Values "true", "false"
6: //windowLess - is control windowless. Values "true", "false"
7: function createSilverlight(controlId, src, elm, width, height, htmlAccess, windowLess)
8: { 9: Silverlight.createObjectEx({ 10: source: src,
11: parentElement: elm,
12: id: controlId,
13: properties: { 14: width: width,
15: height: height,
16: version: "2.0",
17: enableHtmlAccess: htmlAccess,
18: isWindowless: windowLess
19: },
20: events: { } 21: });
22: // Give the keyboard focus to the Silverlight control by default
23: document.body.onload = function()
24: { 25: var silverlightControl = document.getElementById(controlId);
26: if (silverlightControl)
27: silverlightControl.focus();
28: }
29: }
More information could be found here.

Enjoy,
Alex