使用 Silverlight 进行版本检测 [英] Version detection with Silverlight

查看:13
本文介绍了使用 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 控件只有一个 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:

  • major - 主要编号
  • minor - 次要号码
  • build - 版本号
  • revision - 修订号

因此我们可以按如下方式检查特定的内部版本号:

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 Beta 包含一个 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.

请注意,可以通过遍历所有已发布的版本号来对其进行暴力破解.大概就是 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天全站免登陆