Introduced
Silverlight 2.0 Tips and Tricks series
Silverlight.js-some JS help functions for embedding into the Silverlight plug-in and customizing the installation experience to help
Silverlight.supportedUserAgent.js-a function that is used to determine if Silverlight supports the user's browser
Custom launch interface-comprehensive application of three parameters: SplashScreenSource, onsourcedownloadprogresschanged, OnSourceDownloadComplete
Respond to mouse wheel events-to respond and handle mouse wheel events
Online Demo
Http://www.cnblogs.com/webabcd/archive/2008/10/09/1307486.html
Example
1, Silverlight.js and Silverlight.supportedUserAgent.js of the common functions of the demo and description
Silverlightdotjsdemo.html
<!--
Detailed Silverlight.js
Silverlight.js-some JS help functions for embedding into the Silverlight plug-in and customizing the installation experience, and so on, with the latest version downloaded at the following address
Http://code.msdn.microsoft.com/silverlightjs
Silverlight.supportedUserAgent.js-a function that is used to determine whether Silverlight supports the user's browser and that the latest version is downloaded at the following address
Http://code.msdn.microsoft.com/SLsupportedUA
-->
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>Silverlight.js</title>
<script type= "Text/javascript" src= ". /silverlight.js "></script>
<script src= ". /silverlight.supporteduseragent.js "type=" Text/javascript "></script>
<body>
<div id= "Container" >
<a href= "http://go.microsoft.com/fwlink/?LinkID=124807" style= "Text-decoration:none;" >
style= "Border-style:none"/>
</a>
</div>
<script type= "Text/javascript" >
Silverlight.createobject ()-generates an object element with the Silverlight plug-in embedded
Silverlight.createobject (
".. /clientbin/silverlight20.xap ",//. XAP's Address
document.getElementById (' container '),//contains the parent element of this object element
"Slplugin",//ID of object element
{
Width: "100%",
Height: "100%",
minRuntimeVersion: "2.0.31005.0"
},//Silverlight Plug-in property array
{
Onload:onslload,
Onerror:onslerror,
Onsourcedownloadcomplete:onsourcedownloadcomplete
},//Silverlight plug-in event handler array
"Key1=value1,key2=value2",//passes the initialization parameters (in the form of Key=value) for the Silverlight program. Separated by ","
"Mycontext"//context information, which can be obtained in the OnLoad event of the plug-in
);
function Onslload (plugin, usercontext, sender) {
Alert (plugin.id + "-" + usercontext + "-" + sender.tostring ());
}
function Onslerror (sender, args) {
Args-sys.ui.silverlight.erroreventargs type
Erroreventargs.errortype-Error type
Erroreventargs.errormessage-Error message
Erroreventargs.errorcode-Error code
The exception that the program throw can catch at this point
Alert (Args.errortype + "\ n" + args.errormessage + "\ n" + args.errorcode);
}
function OnSourceDownloadComplete (sender, args) {
Alert ("Sourcedownloadcomplete");
}
Silverlight.createobjectex (params)-passes all parameters into an array, within which the arguments in the array are parsed, and then the Silverlight.createobject () is invoked.
Silverlight.default_error_handler = function (sender, args) {}-the default handler for the OnError event, which can be set to NULL if not required
</script>
<script type= "Text/javascript" >
Window.onload = function () {
Getsilverlight ()-Attempt to download the specified version, if you specify an empty string "", try downloading the latest version
Silverlight.getsilverlight ("2.0.31005.0");
IsInstalled ()-Determines whether the specified Silverlight version is installed
Alert (silverlight.isinstalled ("2.0.31005.0"));
Silverlight.onsilverlightinstalled-When using Silverlight.js, if the client does not have a Silverlight plug-in installed, it is automatically installed and then called to refresh the browser. You can override this method to customize the behavior (for example, by CreateObject () to make a newly installed plug-in effective without refreshing). Note: If it is a Silverlight upgrade, this method will not be invoked and the browser must be restarted (only refreshing is not possible)
supportedUserAgent (version, useragent)-Determines whether Silverlight supports the user's browser, omitting useragent is the current browser
Alert (Silverlight.supporteduseragent ("2.0"));
}
</script>
</body>