版本检测与Silverlight [英] Version detection with Silverlight

查看:146
本文介绍了版本检测与Silverlight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能有效地检测版本,对于这个问题,了解的Silverlight实例的任何现有资料目前在浏览器中运行?

How can I efficiently and effectively detect the version and, for that matter, any available information about the instance of Silverlight currently running on the browser?

推荐答案

Silverlight控件只有一个<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.interop.silverlighthost.isversionsupported(VS.95).aspx\"相对=nofollow> IsVersionSupported功能,当你给它一个版本号,例如返回真/假:

The Silverlight control only has an IsVersionSupported function, which returns true / false when you give it a version number, e.g.:

if(slPlugin.isVersionSupported("2.0")) {
  alert("I haz some flavour of Silverlight 2");

您可以根据需要检查构建时具体,因为版本字符串可以包括所有如下:

You can be as specific as you want when checking the build, since the version string can include all of the following:


  • 大 - 主设备号

  • 未成年人 - 次编号

  • 构建 - 内部版本号

  • 修改 - 版本号

因此​​,我们可以检查特定的版本号如下:

So we can check for a specific build number as follows:

if(slPlugin.isVersionSupported("2.0.30523")) {
  alert("I haz Silverlight 2.0.30523, but could be any revision.");

的Silverlight 1.0测试包括了control.settings.version属性,它是与isVersionSupported()方法的取代。这个想法是,你不应该对编程的Silverlight的特定版本。相反,你应该检查客户端是否有至少的优化版本1.0或2.0,等等。

Silverlight 1.0 Beta included a control.settings.version property, which was replaced with the isVersionSupported() method. The idea is that you shouldn't be programming against specific versions of Silverlight. Rather, you should be checking if the client has at least verion 1.0, or 2.0, etc.

这就是说,你可以通过检查的Silverlight插件的描述得到了Firefox中的Silverlight的版本号:

That being said, you can get the Silverlight version number in Firefox by checking the Silverlight plugin description:

alert(navigator.plugins["Silverlight Plug-In"].description);

显示了我的电脑上2.0.30523.8。

Shows '2.0.30523.8' on my computer.

请注意,有可能通过所有已发布的版本号迭代蛮力它。 presumably这就是BrowserHawk做 - 他们将报告的客户端已经安装的Silverlight的版本

Note that it is possible to brute force it by iterating through all released version numbers. Presumably that's what BrowserHawk does - they'll report which version of Silverlight the client has installed.

这篇关于版本检测与Silverlight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆