HomefieldOfView | SPi-V dev

Navigation

user

Javascript Detection for ShockWave: please test

Macromedia suddenly changed the way version numbers are stored in IE, so now the old detction routines don't work as well.

Was wondering if anyone can test this to see if it works for them:

http://www.pinlady.net/stuff/SWVersionTest.htm

seems OK

detected "Shockwave version = 10.1"

Bingo we have a winner hehe :P

simpler?

How about this (replaces lines 29 - 64 in your script):

try{ 
  obj = new ActiveXObject("SWCtl.SWCtl");
  return obj.ShockwaveVersion("");
}catch(e){};

This way, you create an ActiveX control without knowing its version, and then ask it what version it has.

On my systems your version reports 8.5.1 in IE whereas Firefox gives me 10.1. With the above I get 10.1r11 which is the correct version on that system, not 8.5.1.

Related link (from over a year ago):
http://weblogs.macromedia.com/thiggins/archives/2005/01/new_publish_tem....

Heh! It works.

Heh! It works.

Now this is truly bizarre. I was aware of the macromedia links where they supplied some code to detect Shockwave. Here was the relevant portion of their Visual Basic code:

document.write('on error resume next \n');
document.write('set tSWControl = CreateObject("SWCtl.SWCtl") \n');
document.write('if IsObject(tSWControl) then \n');
document.write('tVersionString = tSWControl.ShockwaveVersion("") \n');
document.write('end if');

The thing is, when I tried their VBS code, it never worked. I even saw people on the Macromedia forums complain that their VBS code did not work.

It never occured to me that it was valid in Javascript,however.

BTW, Javascript would not let me enumerate the properties of obj, even though obj.ShockWaveVersion("") works.

This method does not seem to work for the lower versions like ShockWave 7, but that does not really matter. It should still be possible to detect them using new ActiveXObject("SWCtl.SWCtl.7"),
etc...

Since your IE has version 10.1, I do not understand why my brute force technique did not detect it for you. One of the loops should have attempted to do this on your system:

try{ obj=new ActiveXObject("SWCtl.SWCtl.10.1");return 10.1}
catch(e){}

Just out of curiosity, look in your Registry for \HKEY_LOCAL_MACHINE\SOFTWARE\Classes

and see if you can locate the entry: SWCtl.SWCtl.10.1

If it is there, then I do not see why your system would not execute the command: new ActiveXObject("SWCtl.SWCtl.10.1")

Eric

Well, it turns out that you

Well, it turns out that you CAN use the .ShockwaveVersion("") inside Visual Basic.

It turns out that the sample pages at macromedia.com simply embedded the code incorrectly into their web pages. It seems they just screwed up somehow.

It's like they never even bothered to test their own detection code.

Could have saved me alot of trouble.

Alright, thanks to Aldo's

Alright, thanks to Aldo's suggestion I have the new tester here:

http://www.pinlady.net/stuff/SWVersionTest.htm

The only difference is that versions 8 and lower do not allow creating ActiveXObject("SWCtl.SWCtl"), so I specifically test for versions 8, 7 and 6.

For versions 8.5 and higher, using ActiveXObject("SWCtl.SWCtl") along with ShockwaveVersion("") should work just fine.

Eric

sharing variables between vbscript and javascript

The problem with the code on the macromedia pages I linked to was they fail to properly share a variable between the javascript and vbscript environment. I prefer to keep to a single language because of that.

Personally, I don't bother with detecting Shockwave on IE/Windows and Firefox; these browsers have integrated plugin detection and installation that is hard to beat with javascript.