お手軽 Silverlight バージョン判定
getSilverlightVersion() はインストールされている Silverlight のバージョン番号(Major[.Minor])を返します。Silverlight version 3 〜 5 を判定するようにコードを差し替えました。
<html><head><title></title></head><body> <script> var _ie = !!document.uniqueID; function detectSilverlightVersion() { try { var ok, i, obj = _ie ? new ActiveXObject("AgControl.AgControl") : parseInt(/\d+\.\d+/.exec(navigator.plugins[ "Silverlight Plug-In"].description)[0]); for (i = 5; i >= 3; --i) { ok = _ie ? obj.IsVersionSupported(i + ".0") : obj >= i; if (ok) { return i; } } } catch(err) {} return 0; } window.onload = function() { alert(detectSilverlightVersion()); } </script> </body></html>
Silverlight | Result value |
Silverlight3.0.40307.0 | 3.0 |
Silverlight2.0.xxxxx | 0 |
Silverlight1.0.xxxxx | 0 |
インストールされていない | 0 |