Home > Web Front-end > JS Tutorial > Javascript creates Silverlight Plugin and customizes nonSilverlight and lowSilverlight styles_javascript tips

Javascript creates Silverlight Plugin and customizes nonSilverlight and lowSilverlight styles_javascript tips

WBOY
Release: 2016-05-16 18:24:23
Original
935 people have browsed it

By default, the generated page code may look like the following:

Copy the code The code is as follows:




IRERTranscript











We can pass different values ​​to the object object Parameters, such as the loading address of the xap package, onLoad or onError event handler, background color, minimum version number support, etc. For complete parameter information, readers can refer to the summary of param parameter list in Silverlight 3. The object object generally contains an tag, which is used to display the content to be displayed when the client browser does not have the Silverlight plug-in installed. We can customize the content, such as:
Copy code The code is as follows:



< ;param name="onError" value="onSilverlightError" />









When the client browser does not have the Silverlight plug-in installed, the program will display a picture with a hot spot in the corresponding area. The hot spot points to the Silverlight installation address provided by Microsoft. Theoretically, you can specify any custom code to display nonSilverlight effects, but Silverlight does not provide the effects to be displayed in lower versions of Silverlight by default, which is the case of lowSilverlight.
Silverlight can automatically achieve forward compatibility, that is, a Silverlight package compiled under a lower version can run under a higher version. On the contrary, a Silverlight package compiled under a higher version cannot run under a lower version. At this time, the Silverlight plug-in will A default picture is displayed to inform the user to upgrade the plug-in, and a prompt box pops up, as shown below:

Javascript creates Silverlight Plugin and customizes nonSilverlight and lowSilverlight styles_javascript tips

Javascript creates Silverlight Plugin and customizes nonSilverlight and lowSilverlight styles_javascript tips

I personally feel that this user experience is not very good. Just imagine, if there are multiple Silverlight plug-ins on the current page, wouldn't multiple prompt boxes pop up? So how to solve this problem? In fact, in addition to adding object tags directly on the page to render Silverlight, we can also dynamically add Silverlight through javascript scripts. The Silverlight.js script provides us with a series of available methods. For details, you can refer to msdn http://msdn.microsoft.com/zh-cn/library/cc838126(v=VS.95).aspx #isinstalled

 And how to add Silverlight to the page through script, http://msdn.microsoft.com/zh-cn/library/cc265155(v=VS.95).aspx

msdn gives very detailed examples to tell us how to use these script methods. One thing to note is that when using the Silverlight.js file, it must be consistent with the current Silverlight version, otherwise there may be script errors. The corresponding The Silverlight.js file can be downloaded from Microsoft's website. You will find that there are actually many versions available, including versions that support debugging.

There are several issues that need to be paid attention to when using the createObject method parameters:

 1. Parameters are specified in order. If there are parameters that do not need to be passed, they can be replaced by null.

2. The parent element parameter must be specified, which is the parent element of the object tag. You can directly pass the element's id as an object, but it is not supported in Firefox. In this case, you can use the document.getElementById('elementId') statement. Just replace this parameter.

 3. The param list is passed through an array, and the parameter name can be consistent with the name used in the object tag.

 4. If the event list does not have a corresponding page script, a null value will be passed, otherwise a script error will be reported.

5. The last parameter context can be omitted if it is not needed. There is no need to pass null or empty value.

You should have noticed that when using the createObject method, we can specify nonSilverlight effects for Silverlight. This is specified through the altHtml parameter in the param list. In implementation, when we directly use the object tag on the page to render Silverlight You can use the alt attribute to specify nonSilverlight effects, which is the same as inserting HTML code directly into the object tag.
By using the createObject method, we can completely customize the lowSilverlight effect. Here is an example:

Copy code The code is as follows :






  使用 Silverlight.isInstalled()방법은 Silverlight를 사용하는 방법입니다.经安装了,则使用 Silverlight.createObject 방법创建Silverlight对象,否则输流自결정적인 内容.

这里还有一篇文章个人觉得很有用,给大家分享下吧!

http://www.itstrike.cn/Question/Use-JavaScript-to-create-Silverlight-Object-createObject

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template