I do not understand what's going through the mind of a developer who makes a site to display a software version number and does not have a special case for not installed. Incredible.
function doit(){
var parts = Array("ver-major", "ver-minor", "ver-build", "ver-revision");
//try firefox/non-IE version.
var nav = navigator.plugins["Silverlight Plug-In"];
if (nav) {
for (var i = 0; i < 4; i++) {
document.getElementById(parts[i]).innerHTML = parseInt(nav.description.split(".")[i]).toString(); //getControl().isVersionSupported("2.0");
}
} else {
//try the IE one now.
try {
var control = new ActiveXObject('AgControl.AgControl');
//the following would be faster with a binary search, but this is "fast enough" for now.
var vers = Array(1, 0, 0, 0);
loopMatch(control, vers, 0, 1);
loopMatch(control, vers, 1, 1);
loopMatch(control, vers, 2, 10000);
loopMatch(control, vers, 2, 1000);
loopMatch(control, vers, 2, 100);
loopMatch(control, vers, 2, 10);
loopMatch(control, vers, 2, 1);
loopMatch(control, vers, 3, 1);
for (var i = 0; i < 4; i++) {
document.getElementById(parts[i]).innerHTML = vers[i].toString();
}
} catch (e) {
document.getElementById("vers-discrete").innerHTML = "Silverlight not installed.";
}
}
}
function loopMatch(control, vers, idx, inc) {
while(IsSupported(control, vers)){
vers[idx]+=inc;
}
vers[idx] -= inc;
}
function IsSupported(control, ver){
return control.isVersionSupported(ver[0]+ "."+ ver[1] + "." + ver[2] + "." + ver[3]);
}
doit();
All I can say is... "interesting"EDIT: that is the code they are using as of this posting
EDIT: Also, a lot of commenters here are just making jokes (funny ones, sure) but not actually looking at or considering the code required to get the version number.
Press any key to continue.