简体   繁体   中英

How javascript access ActiveXObject

I am trying to check the availability of Flash Player and the version as given below

var a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
if (a) { // a will return null when ActiveX is disabled
    d = a.GetVariable("$version");
if (d) {
   d = d.split(" ")[1].split(",");
   playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
}
}

It returns the correct version if available.

But, I am facing a problem during the following situation -

  1. Suppose there is no flashplayer installed
  2. I have opened my browser (I am using Firefox) and access the above mentioned javascript (embedding inside HTML ), it returns 0.0.0, which is correct
  3. Now, I have installed flash-player and access the same code without closing the browser, it still returning version as 0.0.0 which is wrong
  4. But, if I reopen the browser, it is giving the correct result.

When does the browser load the ActiveXObject? Is there any way to get the correct flash player version without reopening the browser?

I pressume that the version will be returned correctly when you reload the browser, so you could just set a setInterval if no flash is available and check every 30 seconds whether it has become available and reload if it did become available.

Additionally if you place a hidden flash object on the page, in a lot of browsers flash itself will reload any tabs on which it sees a flash object. Or maybe it's the browser itself doing the refreshing, not sure, but I do know at least that if such an object is on the page it will refresh in various browsers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM