问题
Is there a javascript function I can use to detect whether a specific silverlight version is installed in the current browser?
I'm particularly interested in the Silverlight 2 Beta 2 version. I don't want to use the default method of having an image behind the silverlight control which is just shown if the Silverlight plugin doesn't load.
Edit: From link provided in accepted answer:
Include Silverlight.js (from Silverlight SDK)
Silverlight.isInstalled("2.0");
回答1:
Include Silverlight.js (from Silverlight SDK)
Silverlight.isInstalled("4.0")
Resource:
http://msdn.microsoft.com/en-us/library/cc265155(vs.95).aspx
回答2:
Please actually use the latest script available at http://code.msdn.microsoft.com/silverlightjs for the latest updates. This has several fixes in it.
回答3:
var hasSilverlight = Boolean(window.Silverlight);
var hasSilverlight2 = hasSilverlight && Silverlight.isInstalled('2.0');
Etc....
回答4:
Download this script: http://code.msdn.microsoft.com/silverlightjs
And then you can use it like so:
if (Silverlight.isInstalled)
{
alert ("Congrats. Your web browser is enabled with Silverlight Runtime");
}
回答5:
if (Silverlight.isInstalled("1.0")) {
try {
alert("Silverlight Version 1.0 or above is installed");
}
catch (err) {
alert(err.Description);
}
}
else {
alert("No Silverlight is installed");
}
from this video.
Silverlight.isInstalled is always true so version string such as "1.0" must be provided to make it useful.
来源:https://stackoverflow.com/questions/119980/detect-via-javascript-whether-silverlight-is-installed